中国大学慕课小工具

一个中国大学mooc刷课工具,火狐,谷歌,油猴支持.支持自动观看视频/课件/讨论,屏蔽视频题目和静音倍速,作业/测试题库,考试题库,SCOP课程(੧ᐛ੭挂科模式,启动)

  1. // ==UserScript==
  2. // @name 中国大学慕课小工具
  3. // @namespace https://github.com/CodFrm/cxmooc-tools
  4. // @version 2.5.3
  5. // @description 一个中国大学mooc刷课工具,火狐,谷歌,油猴支持.支持自动观看视频/课件/讨论,屏蔽视频题目和静音倍速,作业/测试题库,考试题库,SCOP课程(੧ᐛ੭挂科模式,启动)
  6. // @author CodFrm
  7. // @run-at document-start
  8. // @match *://www.icourse163.org/learn/*
  9. // @match *://www.icourse163.org/spoc/learn/*
  10. // @grant GM_xmlhttpRequest
  11. // @grant GM_notification
  12. // @grant CAT_click
  13. // @grant unsafeWindow
  14. // @license MIT
  15. // @supportURL https://bbs.tampermonkey.net.cn/forum.php?mod=viewthread&tid=63
  16. // @homepage https://bbs.tampermonkey.net.cn/forum.php?mod=viewthread&tid=63
  17. // @antifeature membership
  18. // @antifeature ads
  19. // ==/UserScript==
  20.  
  21. let config = {
  22. answer_ignore: false, //忽略题目,勾选此处将不会答题
  23. auto: true, //全自动挂机,无需手动操作,即可自动观看视频等
  24. rand_answer: false, //随机答案,没有答案的题目将自动的生成一个答案
  25. interval: 1, //时间间隔,当任务点完成后,会等待1分钟然后跳转到下一个任务点
  26. video_multiple: 1, //视频播放倍速,视频播放的倍数,建议不要改动,为1即可,这是危险的功能
  27. video_mute: true, //视频静音,视频自动静音播放
  28. topic_interval: 5,//题目答题间隔,单位为秒
  29. vtoken: "",
  30. };
  31.  
  32. Object.keys(config).forEach(k => {
  33. localStorage[k] = config[k];
  34. });
  35. /******/ (function(modules) { // webpackBootstrap
  36. /******/ // The module cache
  37. /******/ var installedModules = {};
  38. /******/
  39. /******/ // The require function
  40. /******/ function __webpack_require__(moduleId) {
  41. /******/
  42. /******/ // Check if module is in cache
  43. /******/ if(installedModules[moduleId]) {
  44. /******/ return installedModules[moduleId].exports;
  45. /******/ }
  46. /******/ // Create a new module (and put it into the cache)
  47. /******/ var module = installedModules[moduleId] = {
  48. /******/ i: moduleId,
  49. /******/ l: false,
  50. /******/ exports: {}
  51. /******/ };
  52. /******/
  53. /******/ // Execute the module function
  54. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  55. /******/
  56. /******/ // Flag the module as loaded
  57. /******/ module.l = true;
  58. /******/
  59. /******/ // Return the exports of the module
  60. /******/ return module.exports;
  61. /******/ }
  62. /******/
  63. /******/
  64. /******/ // expose the modules object (__webpack_modules__)
  65. /******/ __webpack_require__.m = modules;
  66. /******/
  67. /******/ // expose the module cache
  68. /******/ __webpack_require__.c = installedModules;
  69. /******/
  70. /******/ // define getter function for harmony exports
  71. /******/ __webpack_require__.d = function(exports, name, getter) {
  72. /******/ if(!__webpack_require__.o(exports, name)) {
  73. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  74. /******/ }
  75. /******/ };
  76. /******/
  77. /******/ // define __esModule on exports
  78. /******/ __webpack_require__.r = function(exports) {
  79. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  80. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  81. /******/ }
  82. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  83. /******/ };
  84. /******/
  85. /******/ // create a fake namespace object
  86. /******/ // mode & 1: value is a module id, require it
  87. /******/ // mode & 2: merge all properties of value into the ns
  88. /******/ // mode & 4: return value when already ns object
  89. /******/ // mode & 8|1: behave like require
  90. /******/ __webpack_require__.t = function(value, mode) {
  91. /******/ if(mode & 1) value = __webpack_require__(value);
  92. /******/ if(mode & 8) return value;
  93. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  94. /******/ var ns = Object.create(null);
  95. /******/ __webpack_require__.r(ns);
  96. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  97. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  98. /******/ return ns;
  99. /******/ };
  100. /******/
  101. /******/ // getDefaultExport function for compatibility with non-harmony modules
  102. /******/ __webpack_require__.n = function(module) {
  103. /******/ var getter = module && module.__esModule ?
  104. /******/ function getDefault() { return module['default']; } :
  105. /******/ function getModuleExports() { return module; };
  106. /******/ __webpack_require__.d(getter, 'a', getter);
  107. /******/ return getter;
  108. /******/ };
  109. /******/
  110. /******/ // Object.prototype.hasOwnProperty.call
  111. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  112. /******/
  113. /******/ // __webpack_public_path__
  114. /******/ __webpack_require__.p = "";
  115. /******/
  116. /******/
  117. /******/ // Load entry module and return exports
  118. /******/ return __webpack_require__(__webpack_require__.s = "./src/tampermonkey/course163-pack.ts");
  119. /******/ })
  120. /************************************************************************/
  121. /******/ ({
  122.  
  123. /***/ "./src/config.ts":
  124. /*!***********************!*\
  125. !*** ./src/config.ts ***!
  126. \***********************/
  127. /*! no static exports found */
  128. /***/ (function(module, exports, __webpack_require__) {
  129.  
  130. "use strict";
  131.  
  132. Object.defineProperty(exports, "__esModule", { value: true });
  133. exports.SystemConfig = void 0;
  134. var SystemConfig = /** @class */ (function () {
  135. function SystemConfig() {
  136. }
  137. SystemConfig.version = 2.5;
  138. SystemConfig.url = "https://cx.icodef.com/";
  139. SystemConfig.hotVersion = "2.5.0";
  140. //TODO:优化规则,可以通过ci自动生成匹配规则到tampermonkey和manifest文件中
  141. SystemConfig.match = {
  142. "cx": [
  143. "*://*/mycourse/studentstudy?*",
  144. "*://*/work/doHomeWorkNew?*",
  145. "*://*/work/selectWorkQuestionYiPiYue?*",
  146. "*://*/exam/test/reVersionTestStartNew?*",
  147. "*://*/ztnodedetailcontroller/visitnodedetail?*",
  148. "*://*/antispiderShowVerify.ac*",
  149. "*://*/html/processVerify.ac?*",
  150. "*://*/exam/test/reVersionPaperMarkContentNew?*",
  151. "*://*/ananas/modules/*/index.html?*",
  152. "*://*/exam/test?*",
  153. "*://*/course/*.html?*"
  154. ], "zhs": [
  155. "*://examh5.zhihuishu.com/stuExamWeb.html*",
  156. "*://onlineexamh5new.zhihuishu.com/stuExamWeb.html*",
  157. "*://studyh5.zhihuishu.com/videoStudy.html*",
  158. ], "mooc163": [
  159. "*://www.icourse163.org/learn/*",
  160. "*://www.icourse163.org/spoc/learn/*"
  161. ]
  162. };
  163. SystemConfig.config = {
  164. cx: {
  165. name: "超星",
  166. items: [{
  167. title: "随机答案",
  168. description: "如果题库没有正确的答案会随机选择",
  169. type: "checkbox",
  170. key: "rand_answer",
  171. value: false,
  172. }, {
  173. title: "自动挂机",
  174. description: "进入一个页面就会自动开始挂机,完成一个任务之后会自动进行下一个",
  175. type: "checkbox",
  176. key: "auto",
  177. value: true,
  178. }, {
  179. title: "视频静音",
  180. description: "播放视频时,自动开启静音",
  181. type: "checkbox",
  182. key: "video_mute",
  183. value: true,
  184. }, {
  185. title: "忽略题目",
  186. description: "自动挂机时,忽略掉题目不做,直接跳过",
  187. type: "checkbox",
  188. key: "answer_ignore",
  189. value: false,
  190. }, {
  191. title: "超级模式",
  192. description: "超星平台下,超级模式会自动将flash播放器换成h5播放器",
  193. type: "checkbox",
  194. key: "super_mode",
  195. value: true,
  196. }, {
  197. title: "播放源",
  198. description: "锁定视频播放源,为空为记录最后一次选中的源(公网1,公网2等)",
  199. type: "text",
  200. key: "video_cdn",
  201. value: "默认"
  202. }, {
  203. title: "播放倍速",
  204. description: "视频播放的倍数,1为正常速度(最高16倍,该功能有一定危险)",
  205. type: "text",
  206. key: "video_multiple",
  207. prompt: "这是一个很危险的功能,建议不要进行调整,如果你想调整播放速度请在下方填写yes(智慧树平台播放速度和视频进度无关,最高只能1.5倍速)",
  208. unit: "倍",
  209. value: "1",
  210. }, {
  211. title: "跳转间隔",
  212. description: "视频(题目,任务点)完成后n分钟再继续下一个任务,可以有小数点,例如:0.5=30秒",
  213. type: "text",
  214. key: "interval",
  215. unit: "分",
  216. value: "1",
  217. }, {
  218. title: "做题间隔",
  219. description: "每一道题之间填写答案的时间间隔",
  220. type: "text",
  221. key: "topic_interval",
  222. unit: "秒",
  223. value: "5",
  224. }],
  225. }, zhs: {
  226. name: "智慧树",
  227. items: [{
  228. title: "随机答案",
  229. description: "如果题库没有正确的答案会随机选择",
  230. type: "checkbox",
  231. key: "rand_answer",
  232. value: false,
  233. }, {
  234. title: "自动挂机",
  235. description: "进入一个页面就会自动开始挂机,完成一个任务之后会自动进行下一个",
  236. type: "checkbox",
  237. key: "auto",
  238. value: true,
  239. }, {
  240. title: "视频静音",
  241. description: "播放视频时,自动开启静音",
  242. type: "checkbox",
  243. key: "video_mute",
  244. value: true,
  245. }, {
  246. title: "超级模式",
  247. description: "智慧树平台下,超级模式会让任务完成的倍速成真",
  248. type: "checkbox",
  249. key: "super_mode",
  250. value: true,
  251. }, {
  252. title: "播放倍速",
  253. description: "视频播放的倍数,1为正常速度(最高16倍,该功能有一定危险)",
  254. type: "text",
  255. key: "video_multiple",
  256. prompt: "这是一个很危险的功能,建议不要进行调整,如果你想调整播放速度请在下方填写yes(智慧树平台播放速度和视频进度无关,最高只能1.5倍速)",
  257. unit: "倍",
  258. value: "1",
  259. }, {
  260. title: "跳转间隔",
  261. description: "视频完成后n分钟再继续播放下一个,可以有小数点,例如:0.5=30秒",
  262. type: "text",
  263. key: "interval",
  264. unit: "分",
  265. value: "1",
  266. }, {
  267. title: "做题间隔",
  268. description: "每一道题之间填写答案的时间间隔",
  269. type: "text",
  270. key: "topic_interval",
  271. unit: "秒",
  272. value: "5",
  273. }],
  274. }, mooc163: {
  275. name: "中国大学MOOC",
  276. items: [{
  277. title: "随机答案",
  278. description: "如果题库没有正确的答案会随机选择",
  279. type: "checkbox",
  280. key: "rand_answer",
  281. value: false,
  282. }, {
  283. title: "自动挂机",
  284. description: "进入一个页面就会自动开始挂机,完成一个任务之后会自动进行下一个",
  285. type: "checkbox",
  286. key: "auto",
  287. value: true,
  288. }, {
  289. title: "视频静音",
  290. description: "播放视频时,自动开启静音",
  291. type: "checkbox",
  292. key: "video_mute",
  293. value: true,
  294. }, {
  295. title: "忽略题目",
  296. description: "自动挂机时,忽略掉题目不做,直接跳过",
  297. type: "checkbox",
  298. key: "answer_ignore",
  299. value: false,
  300. }, {
  301. title: "播放倍速",
  302. description: "视频播放的倍数,1为正常速度(最高16倍,该功能有一定危险)",
  303. type: "text",
  304. key: "video_multiple",
  305. prompt: "这是一个很危险的功能,建议不要进行调整,如果你想调整播放速度请在下方填写yes(智慧树平台播放速度和视频进度无关,最高只能1.5倍速)",
  306. unit: "倍",
  307. value: "1",
  308. }, {
  309. title: "跳转间隔",
  310. description: "视频完成后n分钟再继续播放下一个,可以有小数点,例如:0.5=30秒",
  311. type: "text",
  312. key: "interval",
  313. unit: "分",
  314. value: "1",
  315. }, {
  316. title: "做题间隔",
  317. description: "每一道题之间填写答案的时间间隔",
  318. type: "text",
  319. key: "topic_interval",
  320. unit: "秒",
  321. value: "5",
  322. }],
  323. },
  324. };
  325. return SystemConfig;
  326. }());
  327. exports.SystemConfig = SystemConfig;
  328.  
  329.  
  330. /***/ }),
  331.  
  332. /***/ "./src/internal/app/question.ts":
  333. /*!**************************************!*\
  334. !*** ./src/internal/app/question.ts ***!
  335. \**************************************/
  336. /*! no static exports found */
  337. /***/ (function(module, exports, __webpack_require__) {
  338.  
  339. "use strict";
  340.  
  341. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  342. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  343. return new (P || (P = Promise))(function (resolve, reject) {
  344. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  345. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  346. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  347. step((generator = generator.apply(thisArg, _arguments || [])).next());
  348. });
  349. };
  350. var __generator = (this && this.__generator) || function (thisArg, body) {
  351. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  352. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  353. function verb(n) { return function (v) { return step([n, v]); }; }
  354. function step(op) {
  355. if (f) throw new TypeError("Generator is already executing.");
  356. while (_) try {
  357. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  358. if (y = 0, t) op = [op[0] & 2, t.value];
  359. switch (op[0]) {
  360. case 0: case 1: t = op; break;
  361. case 4: _.label++; return { value: op[1], done: false };
  362. case 5: _.label++; y = op[1]; op = [0]; continue;
  363. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  364. default:
  365. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  366. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  367. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  368. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  369. if (t[2]) _.ops.pop();
  370. _.trys.pop(); continue;
  371. }
  372. op = body.call(thisArg, _);
  373. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  374. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  375. }
  376. };
  377. Object.defineProperty(exports, "__esModule", { value: true });
  378. exports.ToolsQuestionBankFacade = exports.ToolsQuestionBank = exports.SwitchTopicType = exports.QuestionStatusString = exports.TopicStatusString = exports.PushAnswer = void 0;
  379. var utils_1 = __webpack_require__(/*! ../utils/utils */ "./src/internal/utils/utils.ts");
  380. var config_1 = __webpack_require__(/*! @App/config */ "./src/config.ts");
  381. var application_1 = __webpack_require__(/*! ../application */ "./src/internal/application.ts");
  382. var PushAnswer = /** @class */ (function () {
  383. function PushAnswer() {
  384. }
  385. PushAnswer.prototype.Equal = function (content1, content2) {
  386. return content1 == content2;
  387. };
  388. return PushAnswer;
  389. }());
  390. exports.PushAnswer = PushAnswer;
  391. var topicStatusMap = new Map();
  392. topicStatusMap.set("ok", "搜索成功").set("random", "随机答案").set("no_support_random", "不支持的随机答案类型").set("no_answer", "题库中没有搜索到答案").set("no_match", "题库中没有符合的答案");
  393. var questionStatusMap = new Map();
  394. questionStatusMap.set("success", "搜索成功").set("network", "题库网络错误").set("incomplete", "题库不全").set("processing", "搜索中...");
  395. function TopicStatusString(status) {
  396. return topicStatusMap.get(status) || "未知错误";
  397. }
  398. exports.TopicStatusString = TopicStatusString;
  399. function QuestionStatusString(status) {
  400. return questionStatusMap.get(status) || "未知错误";
  401. }
  402. exports.QuestionStatusString = QuestionStatusString;
  403. function SwitchTopicType(title) {
  404. switch (title) {
  405. case "单选题": {
  406. return 1;
  407. }
  408. case "多选题": {
  409. return 2;
  410. }
  411. case "判断题": {
  412. return 3;
  413. }
  414. case "填空题": {
  415. return 4;
  416. }
  417. default: {
  418. return null;
  419. }
  420. }
  421. }
  422. exports.SwitchTopicType = SwitchTopicType;
  423. // 小工具题库
  424. var ToolsQuestionBank = /** @class */ (function () {
  425. function ToolsQuestionBank(platform, info) {
  426. this.platform = platform;
  427. this.info = info;
  428. }
  429. ToolsQuestionBank.prototype.SetInfo = function (info) {
  430. this.info = info;
  431. };
  432. ToolsQuestionBank.prototype.GetInfo = function () {
  433. return encodeURIComponent(JSON.stringify(this.info));
  434. };
  435. ToolsQuestionBank.prototype.Answer = function (topic, resolve) {
  436. var _this = this;
  437. application_1.Application.App.log.Debug("答案查询", topic);
  438. var num = 20;
  439. var answer = new Array();
  440. var retStatus = "success";
  441. var next = function (index) {
  442. var body = "info=" + _this.GetInfo() + "&";
  443. var t = index;
  444. for (; t < index + num && t < topic.length; t++) {
  445. var val = topic[t];
  446. body += "topic[" + (t - index) + "]=" + encodeURIComponent((val.topic)) + "&type[" + (t - index) + "]=" + val.type + "&";
  447. }
  448. utils_1.HttpUtils.HttpPost(config_1.SystemConfig.url + "v2/answer?platform=" + _this.platform, body, {
  449. headers: {
  450. "Authorization": application_1.Application.App.config.vtoken,
  451. "X-Version": config_1.SystemConfig.version.toString(),
  452. },
  453. json: true,
  454. success: function (result) { return __awaiter(_this, void 0, void 0, function () {
  455. var status, tmpResult, i, val;
  456. return __generator(this, function (_a) {
  457. switch (_a.label) {
  458. case 0:
  459. status = "success";
  460. tmpResult = new Array();
  461. for (i = 0; i < result.length; i++) {
  462. if (result[i].result == undefined || result[i].result.length <= 0) {
  463. tmpResult.push({
  464. index: index + result[i].index,
  465. topic: result[i].topic,
  466. type: -1,
  467. status: "no_answer",
  468. answers: null,
  469. correct: null,
  470. Equal: this.Equal,
  471. });
  472. status = "incomplete";
  473. continue;
  474. }
  475. val = result[i].result[0];
  476. tmpResult.push({
  477. index: index + result[i].index,
  478. topic: val.topic,
  479. type: val.type,
  480. correct: val.correct,
  481. status: "ok",
  482. Equal: this.Equal,
  483. });
  484. }
  485. answer = answer.concat(tmpResult);
  486. if (status != "success") {
  487. retStatus = status;
  488. }
  489. return [4 /*yield*/, resolve({ status: "processing", answer: tmpResult })];
  490. case 1:
  491. _a.sent();
  492. if (t < topic.length) {
  493. next(t);
  494. }
  495. else {
  496. return [2 /*return*/, resolve({ status: retStatus, answer: answer })];
  497. }
  498. return [2 /*return*/];
  499. }
  500. });
  501. }); },
  502. error: function () {
  503. return resolve({ status: "network", answer: answer });
  504. }
  505. });
  506. };
  507. next(0);
  508. };
  509. ToolsQuestionBank.prototype.Push = function (answer) {
  510. var _this = this;
  511. return new Promise(function (resolve) {
  512. application_1.Application.App.log.Debug("采集提交", answer);
  513. utils_1.HttpUtils.HttpPost(config_1.SystemConfig.url + "answer?platform=" + _this.platform, "info=" + _this.GetInfo() + "&data=" + encodeURIComponent(JSON.stringify(answer)), {
  514. headers: {
  515. "Authorization": application_1.Application.App.config.vtoken,
  516. "X-Version": config_1.SystemConfig.version.toString(),
  517. },
  518. json: true,
  519. success: function (result) {
  520. application_1.Application.App.log.Info("答案自动记录成功,成功获得" + result.add_token_num + "个打码数,剩余数量:" + result.token_num);
  521. resolve("success");
  522. },
  523. error: function () {
  524. resolve("network");
  525. }
  526. });
  527. });
  528. };
  529. ToolsQuestionBank.prototype.Equal = function (content1, content2) {
  530. return utils_1.removeHTML(content1) == utils_1.removeHTML(content2);
  531. };
  532. ToolsQuestionBank.prototype.CheckCourse = function (info) {
  533. var _this = this;
  534. return new Promise(function (resolve) {
  535. info = info || [_this.info];
  536. utils_1.HttpUtils.HttpPost(config_1.SystemConfig.url + "v2/check?platform=" + _this.platform, "info=" + encodeURIComponent(JSON.stringify(info)), {
  537. headers: {
  538. "Authorization": application_1.Application.App.config.vtoken,
  539. "X-Version": config_1.SystemConfig.version.toString(),
  540. },
  541. success: function () {
  542. resolve(0);
  543. }, error: function () {
  544. resolve(-1);
  545. }
  546. });
  547. resolve();
  548. });
  549. };
  550. return ToolsQuestionBank;
  551. }());
  552. exports.ToolsQuestionBank = ToolsQuestionBank;
  553. var ToolsQuestionBankFacade = /** @class */ (function () {
  554. function ToolsQuestionBankFacade(platform, info) {
  555. if (typeof platform == "string") {
  556. this.bank = new ToolsQuestionBank(platform, info);
  557. }
  558. else {
  559. this.bank = platform;
  560. }
  561. this.question = new Array();
  562. }
  563. ToolsQuestionBankFacade.prototype.ClearQuestion = function () {
  564. this.question = new Array();
  565. };
  566. ToolsQuestionBankFacade.prototype.AddQuestion = function (q) {
  567. this.question.push(q);
  568. };
  569. ToolsQuestionBankFacade.prototype.Answer = function (callback) {
  570. var _this = this;
  571. var topic = new Array();
  572. this.question.forEach(function (val) {
  573. var type = val.GetType();
  574. if (type == -1) {
  575. return;
  576. }
  577. topic.push({
  578. topic: (val.GetTopic()),
  579. type: type,
  580. });
  581. });
  582. var status = "success";
  583. this.bank.Answer(topic, function (ret) {
  584. return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
  585. var t, i, answer, question, tmpStatus;
  586. return __generator(this, function (_a) {
  587. switch (_a.label) {
  588. case 0:
  589. if (ret.status != "processing") {
  590. application_1.Application.App.log.Debug("题库返回", ret);
  591. if (ret.status != "success" || status == "success") {
  592. callback(ret.status);
  593. return [2 /*return*/, resolve()];
  594. }
  595. callback(status);
  596. return [2 /*return*/, resolve()];
  597. }
  598. t = application_1.Application.App.config.topic_interval * 1000;
  599. i = 0;
  600. _a.label = 1;
  601. case 1:
  602. if (!(i < ret.answer.length)) return [3 /*break*/, 11];
  603. answer = ret.answer[i];
  604. question = this.question[answer.index];
  605. tmpStatus = answer.status;
  606. if (!(answer.status == "no_answer")) return [3 /*break*/, 3];
  607. status = this.randAnswer(status, tmpStatus, question);
  608. return [4 /*yield*/, utils_1.Sleep(t)];
  609. case 2:
  610. _a.sent();
  611. return [3 /*break*/, 10];
  612. case 3:
  613. if (!(answer.type != question.GetType())) return [3 /*break*/, 4];
  614. tmpStatus = "no_match";
  615. return [3 /*break*/, 6];
  616. case 4: return [4 /*yield*/, question.Fill(answer)];
  617. case 5:
  618. tmpStatus = _a.sent();
  619. _a.label = 6;
  620. case 6:
  621. if (!(tmpStatus == "no_match")) return [3 /*break*/, 8];
  622. status = this.randAnswer(status, tmpStatus, question);
  623. return [4 /*yield*/, utils_1.Sleep(t)];
  624. case 7:
  625. _a.sent();
  626. return [3 /*break*/, 10];
  627. case 8:
  628. question.SetStatus(tmpStatus);
  629. if (!(i < ret.answer.length - 1)) return [3 /*break*/, 10];
  630. return [4 /*yield*/, utils_1.Sleep(t)];
  631. case 9:
  632. _a.sent();
  633. _a.label = 10;
  634. case 10:
  635. i++;
  636. return [3 /*break*/, 1];
  637. case 11: return [2 /*return*/, resolve()];
  638. }
  639. });
  640. }); });
  641. });
  642. };
  643. ToolsQuestionBankFacade.prototype.randAnswer = function (status, tmpStatus, question) {
  644. if (application_1.Application.App.config.rand_answer) {
  645. tmpStatus = question.Random();
  646. }
  647. else {
  648. status = "incomplete";
  649. }
  650. if (tmpStatus == "no_support_random") {
  651. status = "incomplete";
  652. }
  653. question.SetStatus(tmpStatus);
  654. return status;
  655. };
  656. ToolsQuestionBankFacade.prototype.Push = function (callback) {
  657. var answer = new Array();
  658. this.question.forEach(function (val) {
  659. var correct = val.Correct();
  660. if (correct == null || correct.correct == null || correct.type == -1) {
  661. return;
  662. }
  663. answer.push(correct);
  664. });
  665. this.bank.Push(answer).then(function (ret) {
  666. application_1.Application.App.log.Debug("题库返回", ret);
  667. return callback(ret);
  668. });
  669. };
  670. ToolsQuestionBankFacade.prototype.dealOption = function (options) {
  671. for (var i = 0; i < options.length; i++) {
  672. if (typeof options[i].content == "string") {
  673. options[i].content = (options[i].content);
  674. }
  675. }
  676. return options;
  677. };
  678. ToolsQuestionBankFacade.prototype.CheckCourse = function () {
  679. return this.bank.CheckCourse();
  680. };
  681. return ToolsQuestionBankFacade;
  682. }());
  683. exports.ToolsQuestionBankFacade = ToolsQuestionBankFacade;
  684.  
  685.  
  686. /***/ }),
  687.  
  688. /***/ "./src/internal/app/task.ts":
  689. /*!**********************************!*\
  690. !*** ./src/internal/app/task.ts ***!
  691. \**********************************/
  692. /*! no static exports found */
  693. /***/ (function(module, exports, __webpack_require__) {
  694.  
  695. "use strict";
  696.  
  697. var __extends = (this && this.__extends) || (function () {
  698. var extendStatics = function (d, b) {
  699. extendStatics = Object.setPrototypeOf ||
  700. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  701. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  702. return extendStatics(d, b);
  703. };
  704. return function (d, b) {
  705. extendStatics(d, b);
  706. function __() { this.constructor = d; }
  707. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  708. };
  709. })();
  710. Object.defineProperty(exports, "__esModule", { value: true });
  711. exports.Task = void 0;
  712. var event_1 = __webpack_require__(/*! @App/internal/utils/event */ "./src/internal/utils/event.ts");
  713. var Task = /** @class */ (function (_super) {
  714. __extends(Task, _super);
  715. function Task() {
  716. return _super !== null && _super.apply(this, arguments) || this;
  717. }
  718. // 初始化任务
  719. Task.prototype.Init = function () {
  720. return new Promise(function (resolve) {
  721. return resolve();
  722. });
  723. };
  724. // 提交任务,例如topic的类型,可以在本接口内进行提交操作
  725. Task.prototype.Submit = function () {
  726. return new Promise(function (resolve) {
  727. return resolve();
  728. });
  729. };
  730. // 停止任务
  731. Task.prototype.Stop = function () {
  732. return new Promise(function (resolve) {
  733. return resolve();
  734. });
  735. };
  736. // 任务的上下文(对于某些iframe的可能会用到)
  737. Task.prototype.Context = function () {
  738. return window;
  739. };
  740. return Task;
  741. }(event_1.EventListener));
  742. exports.Task = Task;
  743.  
  744.  
  745. /***/ }),
  746.  
  747. /***/ "./src/internal/app/topic.ts":
  748. /*!***********************************!*\
  749. !*** ./src/internal/app/topic.ts ***!
  750. \***********************************/
  751. /*! no static exports found */
  752. /***/ (function(module, exports, __webpack_require__) {
  753.  
  754. "use strict";
  755.  
  756. Object.defineProperty(exports, "__esModule", { value: true });
  757. exports.Topic = void 0;
  758. var application_1 = __webpack_require__(/*! ../application */ "./src/internal/application.ts");
  759. var config_1 = __webpack_require__(/*! @App/config */ "./src/config.ts");
  760. // 题目任务点
  761. var Topic = /** @class */ (function () {
  762. function Topic(content, answer) {
  763. this.answer = answer;
  764. this.context = content;
  765. }
  766. Topic.prototype.SetQueryQuestions = function (queryQuestions) {
  767. this.queryQuestions = queryQuestions;
  768. };
  769. Topic.prototype.addQuestion = function () {
  770. var _this = this;
  771. var questions = this.queryQuestions.QueryQuestions();
  772. this.answer.ClearQuestion();
  773. questions.forEach(function (val) {
  774. _this.answer.AddQuestion(val);
  775. });
  776. };
  777. Topic.prototype.QueryAnswer = function () {
  778. var _this = this;
  779. return new Promise(function (resolve) {
  780. if (_this.lock) {
  781. return resolve("processing");
  782. }
  783. _this.lock = true;
  784. application_1.Application.App.log.Info("题目搜索中...");
  785. _this.addQuestion();
  786. _this.answer.Answer(function (status) {
  787. _this.lock = false;
  788. resolve(status);
  789. if (status == "network") {
  790. return application_1.Application.App.log.Error("题库无法访问,请查看:" + config_1.SystemConfig.url);
  791. }
  792. else if (status == "incomplete") {
  793. return application_1.Application.App.log.Warn("题库答案不全,请手动填写操作");
  794. }
  795. });
  796. });
  797. };
  798. Topic.prototype.CollectAnswer = function () {
  799. var _this = this;
  800. return new Promise(function (resolve) {
  801. application_1.Application.App.log.Debug("收集题目答案", _this.context);
  802. _this.addQuestion();
  803. _this.answer.Push(function (status) {
  804. application_1.Application.App.log.Debug("采集答案返回", status);
  805. resolve();
  806. });
  807. });
  808. };
  809. return Topic;
  810. }());
  811. exports.Topic = Topic;
  812.  
  813.  
  814. /***/ }),
  815.  
  816. /***/ "./src/internal/application.ts":
  817. /*!*************************************!*\
  818. !*** ./src/internal/application.ts ***!
  819. \*************************************/
  820. /*! no static exports found */
  821. /***/ (function(module, exports, __webpack_require__) {
  822.  
  823. "use strict";
  824.  
  825. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  826. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  827. return new (P || (P = Promise))(function (resolve, reject) {
  828. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  829. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  830. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  831. step((generator = generator.apply(thisArg, _arguments || [])).next());
  832. });
  833. };
  834. var __generator = (this && this.__generator) || function (thisArg, body) {
  835. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  836. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  837. function verb(n) { return function (v) { return step([n, v]); }; }
  838. function step(op) {
  839. if (f) throw new TypeError("Generator is already executing.");
  840. while (_) try {
  841. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  842. if (y = 0, t) op = [op[0] & 2, t.value];
  843. switch (op[0]) {
  844. case 0: case 1: t = op; break;
  845. case 4: _.label++; return { value: op[1], done: false };
  846. case 5: _.label++; y = op[1]; op = [0]; continue;
  847. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  848. default:
  849. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  850. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  851. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  852. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  853. if (t[2]) _.ops.pop();
  854. _.trys.pop(); continue;
  855. }
  856. op = body.call(thisArg, _);
  857. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  858. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  859. }
  860. };
  861. Object.defineProperty(exports, "__esModule", { value: true });
  862. exports.Application = exports.AppName = exports.Content = exports.Frontend = exports.Backend = void 0;
  863. var message_1 = __webpack_require__(/*! ./utils/message */ "./src/internal/utils/message.ts");
  864. var utils_1 = __webpack_require__(/*! ./utils/utils */ "./src/internal/utils/utils.ts");
  865. var config_1 = __webpack_require__(/*! @App/config */ "./src/config.ts");
  866. exports.Backend = "backend";
  867. exports.Frontend = "frontend";
  868. exports.Content = "content";
  869. exports.AppName = "cxmooc-tools";
  870. var Application = /** @class */ (function () {
  871. function Application(runEnv, launcher, component) {
  872. Application.app = this;
  873. Application.runEnv = runEnv;
  874. this.runEnvSwitch(runEnv);
  875. this.launcher = launcher;
  876. this.component = component;
  877. }
  878. Object.defineProperty(Application, "App", {
  879. get: function () {
  880. return Application.app;
  881. },
  882. enumerable: false,
  883. configurable: true
  884. });
  885. Object.defineProperty(Application.prototype, "debug", {
  886. get: function () {
  887. return "development" == "development";
  888. },
  889. enumerable: false,
  890. configurable: true
  891. });
  892. Object.defineProperty(Application.prototype, "prod", {
  893. get: function () {
  894. return "development" == "production";
  895. },
  896. enumerable: false,
  897. configurable: true
  898. });
  899. Object.defineProperty(Application.prototype, "config", {
  900. get: function () {
  901. return this.component.get("config");
  902. },
  903. enumerable: false,
  904. configurable: true
  905. });
  906. Object.defineProperty(Application.prototype, "log", {
  907. get: function () {
  908. return this.component.get("logger");
  909. },
  910. enumerable: false,
  911. configurable: true
  912. });
  913. Application.prototype.run = function () {
  914. this.launcher.start();
  915. };
  916. Object.defineProperty(Application.prototype, "IsFrontend", {
  917. get: function () {
  918. return Application.IsFrontend;
  919. },
  920. enumerable: false,
  921. configurable: true
  922. });
  923. Object.defineProperty(Application.prototype, "IsBackend", {
  924. get: function () {
  925. return Application.IsBackend;
  926. },
  927. enumerable: false,
  928. configurable: true
  929. });
  930. Object.defineProperty(Application.prototype, "IsContent", {
  931. get: function () {
  932. return Application.IsContent;
  933. },
  934. enumerable: false,
  935. configurable: true
  936. });
  937. Application.prototype.runEnvSwitch = function (env) {
  938. switch (env) {
  939. case exports.Frontend:
  940. Application.IsFrontend = true;
  941. break;
  942. case exports.Backend:
  943. Application.IsBackend = true;
  944. break;
  945. case exports.Content:
  946. Application.IsContent = true;
  947. break;
  948. }
  949. ;
  950. };
  951. Object.defineProperty(Application.prototype, "Client", {
  952. get: function () {
  953. if (Application.IsFrontend) {
  954. return message_1.NewChromeClientMessage(exports.AppName);
  955. }
  956. return message_1.NewExtensionClientMessage(exports.AppName);
  957. },
  958. enumerable: false,
  959. configurable: true
  960. });
  961. Application.CheckUpdate = function (callback) {
  962. if (Application.IsContent) {
  963. chrome.storage.local.get(["version", "enforce", "hotversion", "url"], function (item) {
  964. return __awaiter(this, void 0, void 0, function () {
  965. return __generator(this, function (_a) {
  966. switch (_a.label) {
  967. case 0: return [4 /*yield*/, callback((config_1.SystemConfig.version < item.version), item)];
  968. case 1:
  969. _a.sent();
  970. return [2 /*return*/];
  971. }
  972. });
  973. });
  974. });
  975. return;
  976. }
  977. utils_1.HttpUtils.HttpGet(config_1.SystemConfig.url + "update?ver=" + config_1.SystemConfig.version, {
  978. json: true,
  979. success: function (json) {
  980. return __awaiter(this, void 0, void 0, function () {
  981. var data;
  982. return __generator(this, function (_a) {
  983. switch (_a.label) {
  984. case 0:
  985. data = {
  986. version: json.version,
  987. url: json.url,
  988. enforce: json.enforce,
  989. hotversion: json.hotversion,
  990. injection: json.injection,
  991. };
  992. chrome.storage && chrome.storage.local.set(data);
  993. return [4 /*yield*/, callback((config_1.SystemConfig.version < data.version), data)];
  994. case 1:
  995. _a.sent();
  996. return [2 /*return*/];
  997. }
  998. });
  999. });
  1000. }, error: function () {
  1001. return __awaiter(this, void 0, void 0, function () {
  1002. return __generator(this, function (_a) {
  1003. switch (_a.label) {
  1004. case 0: return [4 /*yield*/, callback(false, undefined)];
  1005. case 1:
  1006. _a.sent();
  1007. return [2 /*return*/];
  1008. }
  1009. });
  1010. });
  1011. }
  1012. });
  1013. };
  1014. return Application;
  1015. }());
  1016. exports.Application = Application;
  1017.  
  1018.  
  1019. /***/ }),
  1020.  
  1021. /***/ "./src/internal/utils/config.ts":
  1022. /*!**************************************!*\
  1023. !*** ./src/internal/utils/config.ts ***!
  1024. \**************************************/
  1025. /*! no static exports found */
  1026. /***/ (function(module, exports, __webpack_require__) {
  1027.  
  1028. "use strict";
  1029.  
  1030. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  1031. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  1032. return new (P || (P = Promise))(function (resolve, reject) {
  1033. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  1034. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  1035. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  1036. step((generator = generator.apply(thisArg, _arguments || [])).next());
  1037. });
  1038. };
  1039. var __generator = (this && this.__generator) || function (thisArg, body) {
  1040. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  1041. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  1042. function verb(n) { return function (v) { return step([n, v]); }; }
  1043. function step(op) {
  1044. if (f) throw new TypeError("Generator is already executing.");
  1045. while (_) try {
  1046. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  1047. if (y = 0, t) op = [op[0] & 2, t.value];
  1048. switch (op[0]) {
  1049. case 0: case 1: t = op; break;
  1050. case 4: _.label++; return { value: op[1], done: false };
  1051. case 5: _.label++; y = op[1]; op = [0]; continue;
  1052. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  1053. default:
  1054. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  1055. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  1056. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  1057. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  1058. if (t[2]) _.ops.pop();
  1059. _.trys.pop(); continue;
  1060. }
  1061. op = body.call(thisArg, _);
  1062. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  1063. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  1064. }
  1065. };
  1066. Object.defineProperty(exports, "__esModule", { value: true });
  1067. exports.NewFrontendGetConfig = exports.NewBackendConfig = exports.ChromeConfigItems = void 0;
  1068. var utils_1 = __webpack_require__(/*! ./utils */ "./src/internal/utils/utils.ts");
  1069. var application_1 = __webpack_require__(/*! ../application */ "./src/internal/application.ts");
  1070. var config_1 = __webpack_require__(/*! @App/config */ "./src/config.ts");
  1071. // 缓存默认值
  1072. var configDefaultValue = new Map();
  1073. configDefaultValue.set("vtoken", "");
  1074. for (var key in config_1.SystemConfig.config) {
  1075. for (var i = 0; i < config_1.SystemConfig.config[key].items.length; i++) {
  1076. configDefaultValue.set(key + "_" + config_1.SystemConfig.config[key].items[i].key, config_1.SystemConfig.config[key].items[i].value);
  1077. }
  1078. }
  1079. var ChromeConfigItems = /** @class */ (function () {
  1080. function ChromeConfigItems(config) {
  1081. var _this = this;
  1082. this.Namespace = "";
  1083. this.config = config;
  1084. var list = [];
  1085. configDefaultValue.forEach(function (val, key) {
  1086. list.push(key);
  1087. });
  1088. this.config.Watch(list, function (key, val) {
  1089. _this.localCache[key] = val;
  1090. });
  1091. this.localCache = localStorage;
  1092. }
  1093. // 设置配置的命名空间,储存格式为 namepace_configkey
  1094. ChromeConfigItems.prototype.SetNamespace = function (namespace) {
  1095. this.Namespace = namespace + "_";
  1096. };
  1097. ChromeConfigItems.prototype.ConfigList = function () {
  1098. return this.config.ConfigList();
  1099. };
  1100. ChromeConfigItems.prototype.SetNamespaceConfig = function (namespace, key, val) {
  1101. return this.config.SetConfig(namespace + "_" + key, val);
  1102. };
  1103. ChromeConfigItems.prototype.GetNamespaceConfig = function (namespace, key, defaultVal) {
  1104. return this.config.GetConfig(namespace + "_" + key, defaultVal);
  1105. };
  1106. ChromeConfigItems.prototype.GetConfig = function (key, defaultVal) {
  1107. var val = this.config.GetConfig(this.Namespace + key);
  1108. if (val == undefined) {
  1109. return this.config.GetConfig(key, defaultVal);
  1110. }
  1111. return val || defaultVal;
  1112. };
  1113. ChromeConfigItems.prototype.Watch = function (key, callback) {
  1114. this.config.Watch(key, callback);
  1115. };
  1116. Object.defineProperty(ChromeConfigItems.prototype, "super_mode", {
  1117. get: function () {
  1118. return utils_1.toBool(this.GetConfig("super_mode", "true"));
  1119. },
  1120. enumerable: false,
  1121. configurable: true
  1122. });
  1123. Object.defineProperty(ChromeConfigItems.prototype, "vtoken", {
  1124. get: function () {
  1125. return this.GetConfig("vtoken", "");
  1126. },
  1127. enumerable: false,
  1128. configurable: true
  1129. });
  1130. Object.defineProperty(ChromeConfigItems.prototype, "rand_answer", {
  1131. get: function () {
  1132. return utils_1.toBool(this.GetConfig("rand_answer", "false"));
  1133. },
  1134. enumerable: false,
  1135. configurable: true
  1136. });
  1137. Object.defineProperty(ChromeConfigItems.prototype, "auto", {
  1138. get: function () {
  1139. return utils_1.toBool(this.GetConfig("auto", "true"));
  1140. },
  1141. set: function (val) {
  1142. this.SetConfig("auto", utils_1.boolToString(val));
  1143. },
  1144. enumerable: false,
  1145. configurable: true
  1146. });
  1147. Object.defineProperty(ChromeConfigItems.prototype, "video_mute", {
  1148. get: function () {
  1149. return utils_1.toBool(this.GetConfig("video_mute", "true"));
  1150. },
  1151. enumerable: false,
  1152. configurable: true
  1153. });
  1154. Object.defineProperty(ChromeConfigItems.prototype, "answer_ignore", {
  1155. get: function () {
  1156. return utils_1.toBool(this.GetConfig("answer_ignore", "false"));
  1157. },
  1158. enumerable: false,
  1159. configurable: true
  1160. });
  1161. Object.defineProperty(ChromeConfigItems.prototype, "video_cdn", {
  1162. get: function () {
  1163. var val = this.GetConfig("video_cdn");
  1164. if (val == "默认") {
  1165. return "";
  1166. }
  1167. return val;
  1168. },
  1169. enumerable: false,
  1170. configurable: true
  1171. });
  1172. Object.defineProperty(ChromeConfigItems.prototype, "video_multiple", {
  1173. get: function () {
  1174. return parseFloat(this.GetConfig("video_multiple"));
  1175. },
  1176. enumerable: false,
  1177. configurable: true
  1178. });
  1179. Object.defineProperty(ChromeConfigItems.prototype, "interval", {
  1180. get: function () {
  1181. var interval = parseFloat(this.GetConfig("interval", "0.1"));
  1182. interval = interval * 100;
  1183. return Math.floor(utils_1.randNumber(interval - interval / 2, interval + interval / 2)) / 100;
  1184. },
  1185. enumerable: false,
  1186. configurable: true
  1187. });
  1188. ChromeConfigItems.prototype.SetConfig = function (key, val) {
  1189. return this.config.SetConfig(this.Namespace + key, val);
  1190. };
  1191. Object.defineProperty(ChromeConfigItems.prototype, "topic_interval", {
  1192. get: function () {
  1193. return parseInt(this.GetConfig("topic_interval", "5"));
  1194. },
  1195. set: function (val) {
  1196. this.SetConfig("topic_interval", val);
  1197. },
  1198. enumerable: false,
  1199. configurable: true
  1200. });
  1201. return ChromeConfigItems;
  1202. }());
  1203. exports.ChromeConfigItems = ChromeConfigItems;
  1204. // 后台环境中使用
  1205. function NewBackendConfig() {
  1206. var _this = this;
  1207. return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
  1208. var ret;
  1209. return __generator(this, function (_a) {
  1210. switch (_a.label) {
  1211. case 0:
  1212. ret = new backendConfig();
  1213. return [4 /*yield*/, ret.updateCache()];
  1214. case 1:
  1215. _a.sent();
  1216. resolve(ret);
  1217. return [2 /*return*/];
  1218. }
  1219. });
  1220. }); });
  1221. }
  1222. exports.NewBackendConfig = NewBackendConfig;
  1223. var configWatch = /** @class */ (function () {
  1224. function configWatch() {
  1225. this.watchCallback = new Map();
  1226. }
  1227. configWatch.prototype.WatchEvent = function (key, val) {
  1228. var list = this.watchCallback.get(key);
  1229. if (list != undefined) {
  1230. list.forEach(function (v) {
  1231. v(key, val);
  1232. });
  1233. }
  1234. list = this.watchCallback.get("*");
  1235. if (list != undefined) {
  1236. list.forEach(function (v) {
  1237. v(key, val);
  1238. });
  1239. }
  1240. };
  1241. configWatch.prototype.Watch = function (key, callback) {
  1242. var _this = this;
  1243. if (typeof key == "string") {
  1244. this.setWatchMap(key, callback);
  1245. return;
  1246. }
  1247. key.forEach(function (val, index) {
  1248. _this.setWatchMap(val, callback);
  1249. });
  1250. };
  1251. configWatch.prototype.setWatchMap = function (key, callback) {
  1252. var list = this.watchCallback.get(key);
  1253. if (list == undefined) {
  1254. list = new Array();
  1255. }
  1256. list.push(callback);
  1257. this.watchCallback.set(key, list);
  1258. };
  1259. return configWatch;
  1260. }());
  1261. var backendConfig = /** @class */ (function () {
  1262. function backendConfig() {
  1263. var _this = this;
  1264. this.watch = new configWatch();
  1265. chrome.runtime.onMessage.addListener(function (request) {
  1266. if (request.type && request.type == "cxconfig") {
  1267. _this.cache[request.key] = request.value;
  1268. _this.watch.WatchEvent(request.key, request.value);
  1269. _this.updateConfigStorage();
  1270. }
  1271. });
  1272. }
  1273. // 更新配置转为json,存入
  1274. backendConfig.prototype.updateConfigStorage = function () {
  1275. var txt = JSON.stringify(this.cache);
  1276. chrome.storage.sync.set({ "config_storage": txt });
  1277. };
  1278. // 更新缓存
  1279. backendConfig.prototype.updateCache = function () {
  1280. var _this = this;
  1281. return new Promise(function (resolve) {
  1282. chrome.storage.sync.get("config_storage", function (items) {
  1283. if (items["config_storage"]) {
  1284. _this.cache = JSON.parse(items["config_storage"]);
  1285. }
  1286. else {
  1287. _this.cache = {};
  1288. }
  1289. configDefaultValue.forEach(function (val, key) {
  1290. if (_this.cache[key] === undefined) {
  1291. _this.cache[key] = val;
  1292. }
  1293. });
  1294. _this.updateConfigStorage();
  1295. resolve(undefined);
  1296. });
  1297. });
  1298. };
  1299. backendConfig.prototype.GetConfig = function (key, defaultVal) {
  1300. if (this.cache == undefined) {
  1301. application_1.Application.App.log.Fatal("缓存失败!!!");
  1302. return "";
  1303. }
  1304. return this.cache[key] || defaultVal;
  1305. };
  1306. backendConfig.prototype.Watch = function (key, callback) {
  1307. return this.watch.Watch(key, callback);
  1308. };
  1309. backendConfig.prototype.SetConfig = function (key, val) {
  1310. var _this = this;
  1311. return new Promise(function (resolve) {
  1312. var info = {};
  1313. info[key] = val;
  1314. //通知前端和后端
  1315. _this.cache[key] = val;
  1316. chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
  1317. chrome.tabs.sendMessage(tabs[0].id, { type: "cxconfig", key: key, value: val });
  1318. });
  1319. chrome.runtime.sendMessage({ type: "cxconfig", key: key, value: val });
  1320. _this.updateConfigStorage();
  1321. resolve(undefined);
  1322. });
  1323. };
  1324. backendConfig.prototype.ConfigList = function () {
  1325. var _this = this;
  1326. return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
  1327. return __generator(this, function (_a) {
  1328. switch (_a.label) {
  1329. case 0:
  1330. if (this.cache) {
  1331. return [2 /*return*/, resolve(this.cache)];
  1332. }
  1333. return [4 /*yield*/, this.updateCache()];
  1334. case 1:
  1335. _a.sent();
  1336. resolve(this.cache);
  1337. return [2 /*return*/];
  1338. }
  1339. });
  1340. }); });
  1341. };
  1342. return backendConfig;
  1343. }());
  1344. // 前端环境使用
  1345. function NewFrontendGetConfig() {
  1346. return new frontendGetConfig();
  1347. }
  1348. exports.NewFrontendGetConfig = NewFrontendGetConfig;
  1349. var frontendGetConfig = /** @class */ (function () {
  1350. function frontendGetConfig() {
  1351. var _this = this;
  1352. this.watch = new configWatch();
  1353. this.cache = window.configData || localStorage;
  1354. window.addEventListener('message', function (event) {
  1355. if (event.data.type && event.data.type == "cxconfig") {
  1356. application_1.Application.App.log.Info("配置更新:" + event.data.key + "=" + event.data.value);
  1357. _this.cache[event.data.key] = event.data.value;
  1358. _this.watch.WatchEvent(event.data.key, event.data.value);
  1359. }
  1360. });
  1361. }
  1362. frontendGetConfig.prototype.GetConfig = function (key, defaultVal) {
  1363. if (window.GM_getValue) {
  1364. return window.GM_getValue(key, defaultVal);
  1365. }
  1366. return this.cache[key] || defaultVal;
  1367. };
  1368. frontendGetConfig.prototype.Watch = function (key, callback) {
  1369. return this.watch.Watch(key, callback);
  1370. };
  1371. frontendGetConfig.prototype.SetConfig = function (key, val) {
  1372. return __awaiter(this, void 0, void 0, function () {
  1373. return __generator(this, function (_a) {
  1374. this.cache[key] = val;
  1375. if (window.GM_setValue) {
  1376. return [2 /*return*/, window.GM_setValue(key, val)];
  1377. }
  1378. return [2 /*return*/, application_1.Application.App.Client.Send({
  1379. type: "GM_setValue", details: { key: key, val: val },
  1380. })];
  1381. });
  1382. });
  1383. };
  1384. frontendGetConfig.prototype.ConfigList = function () {
  1385. return this.cache;
  1386. };
  1387. return frontendGetConfig;
  1388. }());
  1389.  
  1390.  
  1391. /***/ }),
  1392.  
  1393. /***/ "./src/internal/utils/event.ts":
  1394. /*!*************************************!*\
  1395. !*** ./src/internal/utils/event.ts ***!
  1396. \*************************************/
  1397. /*! no static exports found */
  1398. /***/ (function(module, exports, __webpack_require__) {
  1399.  
  1400. "use strict";
  1401.  
  1402. Object.defineProperty(exports, "__esModule", { value: true });
  1403. exports.EventListener = void 0;
  1404. var EventListener = /** @class */ (function () {
  1405. function EventListener() {
  1406. this.event = {};
  1407. }
  1408. EventListener.prototype.addEventListener = function (event, callback) {
  1409. if (!this.event[event]) {
  1410. this.event[event] = new Array();
  1411. }
  1412. this.event[event].push({
  1413. callback: callback, param: { once: false },
  1414. });
  1415. };
  1416. EventListener.prototype.addEventListenerOnce = function (event, callback) {
  1417. if (!this.event[event]) {
  1418. this.event[event] = new Array();
  1419. }
  1420. this.event[event].push({
  1421. callback: callback, param: { once: true },
  1422. });
  1423. };
  1424. EventListener.prototype.callEvent = function (event) {
  1425. var _this = this;
  1426. var args = [];
  1427. for (var _i = 1; _i < arguments.length; _i++) {
  1428. args[_i - 1] = arguments[_i];
  1429. }
  1430. if (!this.event[event]) {
  1431. return;
  1432. }
  1433. var del = new Array();
  1434. this.event[event].forEach(function (v, index) {
  1435. v.callback.apply(_this, args);
  1436. if (v.param.once) {
  1437. del.push(index);
  1438. }
  1439. });
  1440. del.forEach(function (v, index) {
  1441. _this.event[event].splice(v - index, 1);
  1442. });
  1443. };
  1444. return EventListener;
  1445. }());
  1446. exports.EventListener = EventListener;
  1447.  
  1448.  
  1449. /***/ }),
  1450.  
  1451. /***/ "./src/internal/utils/hook.ts":
  1452. /*!************************************!*\
  1453. !*** ./src/internal/utils/hook.ts ***!
  1454. \************************************/
  1455. /*! no static exports found */
  1456. /***/ (function(module, exports, __webpack_require__) {
  1457.  
  1458. "use strict";
  1459.  
  1460. Object.defineProperty(exports, "__esModule", { value: true });
  1461. exports.Hook = void 0;
  1462. var application_1 = __webpack_require__(/*! @App/internal/application */ "./src/internal/application.ts");
  1463. var Hook = /** @class */ (function () {
  1464. function Hook(func, context) {
  1465. this.context = context || window;
  1466. this.func = func;
  1467. }
  1468. Hook.prototype.Middleware = function (call) {
  1469. var name;
  1470. if (typeof this.func == "string") {
  1471. name = this.func;
  1472. }
  1473. else {
  1474. name = this.func.name;
  1475. }
  1476. var old = this.context[name];
  1477. this.context[name] = function () {
  1478. var args = [old];
  1479. for (var _i = 0; _i < arguments.length; _i++) {
  1480. args[_i + 1] = arguments[_i];
  1481. }
  1482. return call.apply(this, args);
  1483. };
  1484. };
  1485. Hook.HookAjaxRespond = function (url, call) {
  1486. var _this = this;
  1487. if (!this.once) {
  1488. this.match_list = new Map();
  1489. var self_1 = this;
  1490. var hookXMLHttpRequest = new Hook("open", application_1.Application.GlobalContext.XMLHttpRequest.prototype);
  1491. hookXMLHttpRequest.Middleware(function (next) {
  1492. var _this = this;
  1493. var args = [];
  1494. for (var _a = 1; _a < arguments.length; _a++) {
  1495. args[_a - 1] = arguments[_a];
  1496. }
  1497. self_1.match_list.forEach(function (val, key) {
  1498. if (args[1].indexOf(key) != -1) {
  1499. Object.defineProperty(_this, "responseText", {
  1500. configurable: true,
  1501. get: function () {
  1502. return val.call(this, args[1], this.response);
  1503. }
  1504. });
  1505. }
  1506. });
  1507. return next.apply(this, args);
  1508. });
  1509. this.once = true;
  1510. }
  1511. if (typeof url == "string") {
  1512. this.match_list.set(url, call);
  1513. }
  1514. else {
  1515. url.forEach(function (v) {
  1516. _this.match_list.set(v, call);
  1517. });
  1518. }
  1519. };
  1520. return Hook;
  1521. }());
  1522. exports.Hook = Hook;
  1523.  
  1524.  
  1525. /***/ }),
  1526.  
  1527. /***/ "./src/internal/utils/log.ts":
  1528. /*!***********************************!*\
  1529. !*** ./src/internal/utils/log.ts ***!
  1530. \***********************************/
  1531. /*! no static exports found */
  1532. /***/ (function(module, exports, __webpack_require__) {
  1533.  
  1534. "use strict";
  1535.  
  1536. var __spreadArrays = (this && this.__spreadArrays) || function () {
  1537. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  1538. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  1539. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  1540. r[k] = a[j];
  1541. return r;
  1542. };
  1543. Object.defineProperty(exports, "__esModule", { value: true });
  1544. exports.EmptyLog = exports.PageLog = exports.ConsoleLog = void 0;
  1545. var application_1 = __webpack_require__(/*! ../application */ "./src/internal/application.ts");
  1546. __webpack_require__(/*! ../../views/common */ "./src/views/common.ts");
  1547. var utils_1 = __webpack_require__(/*! @App/internal/utils/utils */ "./src/internal/utils/utils.ts");
  1548. // 开发者工具f12处打印日志
  1549. var ConsoleLog = /** @class */ (function () {
  1550. function ConsoleLog() {
  1551. }
  1552. ConsoleLog.prototype.getNowTime = function () {
  1553. var time = new Date();
  1554. return time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds();
  1555. };
  1556. ConsoleLog.prototype.Debug = function () {
  1557. var args = [];
  1558. for (var _i = 0; _i < arguments.length; _i++) {
  1559. args[_i] = arguments[_i];
  1560. }
  1561. application_1.Application.App.debug && console.info.apply(console, __spreadArrays(["[debug", this.getNowTime(), "]"], args));
  1562. return this;
  1563. };
  1564. ConsoleLog.prototype.Info = function () {
  1565. var args = [];
  1566. for (var _i = 0; _i < arguments.length; _i++) {
  1567. args[_i] = arguments[_i];
  1568. }
  1569. application_1.Application.App.debug && console.info.apply(console, __spreadArrays(["[info", this.getNowTime(), "]"], args));
  1570. return this;
  1571. };
  1572. ConsoleLog.prototype.Warn = function () {
  1573. var args = [];
  1574. for (var _i = 0; _i < arguments.length; _i++) {
  1575. args[_i] = arguments[_i];
  1576. }
  1577. console.warn.apply(console, __spreadArrays(["[warn", this.getNowTime(), "]"], args));
  1578. return this;
  1579. };
  1580. ConsoleLog.prototype.Error = function () {
  1581. var args = [];
  1582. for (var _i = 0; _i < arguments.length; _i++) {
  1583. args[_i] = arguments[_i];
  1584. }
  1585. console.error.apply(console, __spreadArrays(["[error", this.getNowTime(), "]"], args));
  1586. return this;
  1587. };
  1588. ConsoleLog.prototype.Fatal = function () {
  1589. var args = [];
  1590. for (var _i = 0; _i < arguments.length; _i++) {
  1591. args[_i] = arguments[_i];
  1592. }
  1593. console.error.apply(console, __spreadArrays(["[fatal", this.getNowTime(), "]"], args));
  1594. return this;
  1595. };
  1596. return ConsoleLog;
  1597. }());
  1598. exports.ConsoleLog = ConsoleLog;
  1599. var PageLog = /** @class */ (function () {
  1600. function PageLog() {
  1601. var _this = this;
  1602. this.el = undefined;
  1603. window.addEventListener("load", function () {
  1604. _this.div = document.createElement("div");
  1605. // 主要布局
  1606. _this.div.innerHTML = "\n <div class=\"head\" id=\"tools-head\"> \n <span>\u5C0F\u5DE5\u5177\u901A\u77E5\u6761</span> \n <label class=\"switch\" style=\"width:90px\">\n <input class=\"checkbox-input\" id=\"checkbox\" type=\"checkbox\" checked=\"checked\">\n <label class=\"checkbox\" for=\"checkbox\"></label>\n <span>\u684C\u9762\u901A\u77E5</span>\n </label>\n <span class=\"close\" style=\"float:right; cursor:pointer; margin-right:5px;\">x</span>\n </div>\n <div class=\"main\">\n <div class=\"tools-notice-content\"></div>\n </div>\n ";
  1607. _this.div.className = "tools-logger-panel";
  1608. document.body.appendChild(_this.div);
  1609. _this.el = _this.div.querySelector(".tools-notice-content");
  1610. _this.div.querySelector(".close").onclick = function () {
  1611. _this.el = undefined;
  1612. _this.div.remove();
  1613. };
  1614. var checkbox = _this.div.querySelector("#checkbox");
  1615. checkbox.checked = (application_1.Application.App.config.GetConfig("is_notify") || "true") == "true";
  1616. _this.is_notify = checkbox.checked;
  1617. if (!checkbox.checked) {
  1618. checkbox.removeAttribute("checked");
  1619. }
  1620. var self = _this;
  1621. checkbox.addEventListener("change", function () {
  1622. self.is_notify = this.checked;
  1623. application_1.Application.App.config.SetConfig("is_notify", this.checked.toString());
  1624. });
  1625. setTimeout(function () {
  1626. application_1.Application.CheckUpdate(function (isnew, data) {
  1627. if (data == undefined) {
  1628. _this.Info("检查更新失败.");
  1629. return;
  1630. }
  1631. var html = "";
  1632. if (isnew) {
  1633. html += "<span>[有新版本]</span>";
  1634. }
  1635. html += data.injection;
  1636. _this.Info(html);
  1637. });
  1638. }, 1000);
  1639. //支持拖拽移动
  1640. function getProperty(ele, prop) {
  1641. return parseInt(window.getComputedStyle(ele)[prop]);
  1642. }
  1643. _this.div.style.left = application_1.Application.App.config.GetConfig("notify_tools_x");
  1644. _this.div.style.top = application_1.Application.App.config.GetConfig("notify_tools_y");
  1645. var head = _this.div.querySelector("#tools-head");
  1646. head.onmousedown = function (downEvent) {
  1647. var relaX = downEvent.clientX - _this.div.offsetLeft;
  1648. var relaY = downEvent.clientY - _this.div.offsetTop;
  1649. var windowWidth = window.innerWidth;
  1650. var windowHeight = window.innerHeight;
  1651. var containerWidth = getProperty(_this.div, "width");
  1652. var containerHeight = getProperty(_this.div, "height");
  1653. document.onmousemove = function (moveEvent) {
  1654. var targetX = moveEvent.clientX - relaX;
  1655. var targetY = moveEvent.clientY - relaY;
  1656. if (targetX <= 0)
  1657. targetX = 0;
  1658. if (targetY <= 0)
  1659. targetY = 0;
  1660. if (targetX >= windowWidth - containerWidth)
  1661. targetX = windowWidth - containerWidth;
  1662. if (targetY >= windowHeight - containerHeight)
  1663. targetY = windowHeight - containerHeight;
  1664. _this.div.style.left = targetX + "px";
  1665. _this.div.style.top = targetY + "px";
  1666. };
  1667. document.onmouseup = function () {
  1668. document.onmouseup = null;
  1669. document.onmousemove = null;
  1670. application_1.Application.App.config.SetConfig("notify_tools_x", _this.div.style.left);
  1671. application_1.Application.App.config.SetConfig("notify_tools_y", _this.div.style.top);
  1672. };
  1673. };
  1674. });
  1675. }
  1676. PageLog.prototype.getNowTime = function () {
  1677. var time = new Date();
  1678. return time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds();
  1679. };
  1680. PageLog.prototype.first = function (text, color, background) {
  1681. var new_log = document.createElement("div");
  1682. new_log.innerHTML =
  1683. "\n <div class=\"log\" style=\"border-color: " +
  1684. background +
  1685. "; background-color: " +
  1686. background +
  1687. ";\">\n <p><span style=\"color:" +
  1688. color +
  1689. ";\">" +
  1690. text +
  1691. "</span></p>\n </div>\n ";
  1692. //插入第一个元素前
  1693. var first = document
  1694. .getElementsByClassName("tools-notice-content")[0]
  1695. .getElementsByTagName("div");
  1696. document.querySelector(".tools-notice-content").insertBefore(new_log, first[0]);
  1697. };
  1698. PageLog.prototype.toStr = function () {
  1699. var args = [];
  1700. for (var _i = 0; _i < arguments.length; _i++) {
  1701. args[_i] = arguments[_i];
  1702. }
  1703. var text = "";
  1704. for (var i = 0; i < args.length; i++) {
  1705. if (typeof args[i] == "object") {
  1706. text += args[i].toString() + "\n";
  1707. }
  1708. else {
  1709. text += args[i] + "\n";
  1710. }
  1711. }
  1712. return text.substring(0, text.length - 1);
  1713. };
  1714. PageLog.prototype.Debug = function () {
  1715. var args = [];
  1716. for (var _i = 0; _i < arguments.length; _i++) {
  1717. args[_i] = arguments[_i];
  1718. }
  1719. console.info.apply(console, __spreadArrays(["[debug", this.getNowTime(), "]"], args));
  1720. return this;
  1721. };
  1722. PageLog.prototype.Info = function () {
  1723. var args = [];
  1724. for (var _i = 0; _i < arguments.length; _i++) {
  1725. args[_i] = arguments[_i];
  1726. }
  1727. var text = this.toStr.apply(this, args);
  1728. if (this.el) {
  1729. this.first(text, "#409EFF", "rgba(121, 187, 255, 0.2)");
  1730. }
  1731. else {
  1732. console.info.apply(console, __spreadArrays(["[info", this.getNowTime(), "]"], args));
  1733. }
  1734. return this;
  1735. };
  1736. PageLog.prototype.Warn = function () {
  1737. var args = [];
  1738. for (var _i = 0; _i < arguments.length; _i++) {
  1739. args[_i] = arguments[_i];
  1740. }
  1741. var text = this.toStr.apply(this, args);
  1742. if (this.el) {
  1743. this.first(text, "#5C3C00", "rgba(250, 236, 216, 0.4)");
  1744. }
  1745. console.warn.apply(console, __spreadArrays(["[warn", this.getNowTime(), "]"], args));
  1746. if (document.hidden && localStorage["is_notify"] == "true") {
  1747. utils_1.Noifications({
  1748. title: "网课小工具",
  1749. text: text + "\n3秒后自动关闭",
  1750. timeout: 3000,
  1751. });
  1752. }
  1753. return this;
  1754. };
  1755. PageLog.prototype.Error = function () {
  1756. var args = [];
  1757. for (var _i = 0; _i < arguments.length; _i++) {
  1758. args[_i] = arguments[_i];
  1759. }
  1760. var text = this.toStr.apply(this, args);
  1761. if (this.el) {
  1762. this.first(text, "#FFF0F0", "rgba(253, 226, 226, 0.5)");
  1763. }
  1764. console.error.apply(console, __spreadArrays(["[error", this.getNowTime(), "]"], args));
  1765. if (localStorage["is_notify"] == "true") {
  1766. utils_1.Noifications({
  1767. title: "网课小工具",
  1768. text: text,
  1769. });
  1770. }
  1771. return this;
  1772. };
  1773. PageLog.prototype.Fatal = function () {
  1774. var args = [];
  1775. for (var _i = 0; _i < arguments.length; _i++) {
  1776. args[_i] = arguments[_i];
  1777. }
  1778. var text = this.toStr.apply(this, args);
  1779. if (this.el) {
  1780. this.first(text, "#ff0000", "rgba(253, 226, 226, 0.5)");
  1781. }
  1782. console.error.apply(console, __spreadArrays(["[fatal", this.getNowTime(), "]"], args));
  1783. utils_1.Noifications({
  1784. title: "网课小工具",
  1785. text: text,
  1786. });
  1787. return this;
  1788. };
  1789. return PageLog;
  1790. }());
  1791. exports.PageLog = PageLog;
  1792. var EmptyLog = /** @class */ (function () {
  1793. function EmptyLog() {
  1794. }
  1795. EmptyLog.prototype.Debug = function () {
  1796. var args = [];
  1797. for (var _i = 0; _i < arguments.length; _i++) {
  1798. args[_i] = arguments[_i];
  1799. }
  1800. return this;
  1801. };
  1802. EmptyLog.prototype.Info = function () {
  1803. var args = [];
  1804. for (var _i = 0; _i < arguments.length; _i++) {
  1805. args[_i] = arguments[_i];
  1806. }
  1807. return this;
  1808. };
  1809. EmptyLog.prototype.Warn = function () {
  1810. var args = [];
  1811. for (var _i = 0; _i < arguments.length; _i++) {
  1812. args[_i] = arguments[_i];
  1813. }
  1814. return this;
  1815. };
  1816. EmptyLog.prototype.Error = function () {
  1817. var args = [];
  1818. for (var _i = 0; _i < arguments.length; _i++) {
  1819. args[_i] = arguments[_i];
  1820. }
  1821. return this;
  1822. };
  1823. EmptyLog.prototype.Fatal = function () {
  1824. var args = [];
  1825. for (var _i = 0; _i < arguments.length; _i++) {
  1826. args[_i] = arguments[_i];
  1827. }
  1828. return this;
  1829. };
  1830. return EmptyLog;
  1831. }());
  1832. exports.EmptyLog = EmptyLog;
  1833.  
  1834.  
  1835. /***/ }),
  1836.  
  1837. /***/ "./src/internal/utils/message.ts":
  1838. /*!***************************************!*\
  1839. !*** ./src/internal/utils/message.ts ***!
  1840. \***************************************/
  1841. /*! no static exports found */
  1842. /***/ (function(module, exports, __webpack_require__) {
  1843.  
  1844. "use strict";
  1845.  
  1846. var __extends = (this && this.__extends) || (function () {
  1847. var extendStatics = function (d, b) {
  1848. extendStatics = Object.setPrototypeOf ||
  1849. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1850. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1851. return extendStatics(d, b);
  1852. };
  1853. return function (d, b) {
  1854. extendStatics(d, b);
  1855. function __() { this.constructor = d; }
  1856. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1857. };
  1858. })();
  1859. Object.defineProperty(exports, "__esModule", { value: true });
  1860. exports.NewChromeClientMessage = exports.NewChromeServerMessage = exports.NewExtensionClientMessage = exports.NewExtensionServerMessage = void 0;
  1861. function NewExtensionServerMessage(port) {
  1862. return new extensionServerMessage(port);
  1863. }
  1864. exports.NewExtensionServerMessage = NewExtensionServerMessage;
  1865. var extensionServerMessage = /** @class */ (function () {
  1866. function extensionServerMessage(port) {
  1867. this.port = port;
  1868. this.recv();
  1869. }
  1870. extensionServerMessage.prototype.recv = function () {
  1871. var _this = this;
  1872. //监听消息
  1873. chrome.runtime.onConnect.addListener(function (port) {
  1874. if (port.name != _this.port) {
  1875. return;
  1876. }
  1877. port.onMessage.addListener(function (request) {
  1878. _this.acceptCallback(new extensionClientMessage(port), request);
  1879. });
  1880. });
  1881. };
  1882. extensionServerMessage.prototype.Accept = function (callback) {
  1883. this.acceptCallback = callback;
  1884. };
  1885. return extensionServerMessage;
  1886. }());
  1887. var msg = /** @class */ (function () {
  1888. function msg(tag) {
  1889. this.tag = tag;
  1890. }
  1891. msg.prototype.Recv = function (callback) {
  1892. this.recvCallback = callback;
  1893. };
  1894. return msg;
  1895. }());
  1896. // 扩展中使用
  1897. function NewExtensionClientMessage(tag) {
  1898. return new extensionClientMessage(tag);
  1899. }
  1900. exports.NewExtensionClientMessage = NewExtensionClientMessage;
  1901. var extensionClientMessage = /** @class */ (function (_super) {
  1902. __extends(extensionClientMessage, _super);
  1903. function extensionClientMessage(param) {
  1904. var _this = this;
  1905. if (typeof param === 'string') {
  1906. _this = _super.call(this, param) || this;
  1907. _this.connect();
  1908. }
  1909. else {
  1910. _this.conn = param;
  1911. }
  1912. _this.recv();
  1913. return _this;
  1914. }
  1915. extensionClientMessage.prototype.connect = function () {
  1916. this.conn = chrome.runtime.connect({ name: this.tag });
  1917. };
  1918. extensionClientMessage.prototype.recv = function () {
  1919. var _this = this;
  1920. this.conn.onMessage.addListener(function (response) {
  1921. _this.recvCallback(response);
  1922. });
  1923. };
  1924. extensionClientMessage.prototype.Send = function (msg) {
  1925. this.conn.postMessage(msg);
  1926. };
  1927. return extensionClientMessage;
  1928. }(msg));
  1929. // 浏览器中使用
  1930. function NewChromeServerMessage(tag) {
  1931. return new chromeServerMessage(tag);
  1932. }
  1933. exports.NewChromeServerMessage = NewChromeServerMessage;
  1934. var chromeServerMessage = /** @class */ (function () {
  1935. function chromeServerMessage(tag) {
  1936. this.tag = tag;
  1937. this.recv();
  1938. }
  1939. chromeServerMessage.prototype.recv = function () {
  1940. var _this = this;
  1941. window.addEventListener('message', function (event) {
  1942. if (event.data.tag == _this.tag && event.data.conn_tag && event.data.source == "client") {
  1943. _this.acceptCallback(new chromeClientMessage(_this.tag, event.data.conn_tag), event.data.msg);
  1944. }
  1945. });
  1946. };
  1947. chromeServerMessage.prototype.Accept = function (callback) {
  1948. this.acceptCallback = callback;
  1949. };
  1950. return chromeServerMessage;
  1951. }());
  1952. function NewChromeClientMessage(tag) {
  1953. return new chromeClientMessage(tag);
  1954. }
  1955. exports.NewChromeClientMessage = NewChromeClientMessage;
  1956. var chromeClientMessage = /** @class */ (function (_super) {
  1957. __extends(chromeClientMessage, _super);
  1958. function chromeClientMessage(tag, conn) {
  1959. var _this = this;
  1960. if (conn !== undefined) {
  1961. _this = _super.call(this, tag) || this;
  1962. _this.connTag = conn;
  1963. _this.source = "server";
  1964. }
  1965. else {
  1966. _this = _super.call(this, tag) || this;
  1967. _this.connect();
  1968. _this.source = "client";
  1969. }
  1970. return _this;
  1971. }
  1972. chromeClientMessage.prototype.connect = function () {
  1973. var _this = this;
  1974. this.connTag = Math.random();
  1975. window.addEventListener('message', function (event) {
  1976. if (event.data.tag == _this.tag && event.data.conn_tag == _this.connTag && event.data.source == "server") {
  1977. _this.recvCallback && _this.recvCallback(event.data.msg);
  1978. }
  1979. });
  1980. };
  1981. chromeClientMessage.prototype.Send = function (msg) {
  1982. window.postMessage({ tag: this.tag, conn_tag: this.connTag, msg: msg, source: this.source }, '*');
  1983. };
  1984. return chromeClientMessage;
  1985. }(msg));
  1986.  
  1987.  
  1988. /***/ }),
  1989.  
  1990. /***/ "./src/internal/utils/utils.ts":
  1991. /*!*************************************!*\
  1992. !*** ./src/internal/utils/utils.ts ***!
  1993. \*************************************/
  1994. /*! no static exports found */
  1995. /***/ (function(module, exports, __webpack_require__) {
  1996.  
  1997. "use strict";
  1998.  
  1999. Object.defineProperty(exports, "__esModule", { value: true });
  2000. exports.Sleep = exports.UntrustedClick = exports.boolToString = exports.toBool = exports.Noifications = exports.isPhone = exports.getImageBase64 = exports.protocolPrompt = exports.dealHotVersion = exports.substrex = exports.removeHTML = exports.removeHTMLTag = exports.post = exports.get = exports.createBtn = exports.randNumber = exports.RemoveInjected = exports.syncSetChromeStorageLocal = exports.syncGetChromeStorageLocal = exports.InjectedBySrc = exports.Injected = exports.HttpUtils = void 0;
  2001. var application_1 = __webpack_require__(/*! ../application */ "./src/internal/application.ts");
  2002. var HttpUtils = /** @class */ (function () {
  2003. function HttpUtils() {
  2004. }
  2005. HttpUtils.Request = function (info) {
  2006. if (application_1.Application.App.IsBackend) {
  2007. fetch(info.url, info).then(function (body) {
  2008. if (info.json) {
  2009. return body.json();
  2010. }
  2011. else {
  2012. return body.text();
  2013. }
  2014. }).then(function (body) {
  2015. info.success && info.success(body);
  2016. }).catch(function () {
  2017. info.error && info.error();
  2018. });
  2019. return;
  2020. }
  2021. HttpUtils.crossDomainRequest(info);
  2022. };
  2023. HttpUtils.errorCode = function (ret) {
  2024. if (!ret.code) {
  2025. return false;
  2026. }
  2027. switch (ret.code) {
  2028. case -1: {
  2029. application_1.Application.App.log.Info(ret.msg);
  2030. break;
  2031. }
  2032. case -2: {
  2033. application_1.Application.App.log.Warn(ret.msg);
  2034. break;
  2035. }
  2036. case 1: {
  2037. application_1.Application.App.log.Info(ret.msg);
  2038. return false;
  2039. }
  2040. default: {
  2041. return false;
  2042. }
  2043. }
  2044. return true;
  2045. };
  2046. HttpUtils.crossDomainRequest = function (info) {
  2047. if (window.hasOwnProperty('GM_xmlhttpRequest')) {
  2048. //兼容油猴
  2049. info.data = info.body;
  2050. info.onreadystatechange = function (response) {
  2051. if (response.readyState == 4) {
  2052. if (response.status == 200) {
  2053. if (info.json) {
  2054. var ret = JSON.parse(response.responseText);
  2055. if (HttpUtils.errorCode(ret)) {
  2056. info.error && info.error();
  2057. return;
  2058. }
  2059. info.success && info.success(ret);
  2060. }
  2061. else {
  2062. info.success && info.success(response.responseText);
  2063. }
  2064. }
  2065. else {
  2066. info.error && info.error();
  2067. }
  2068. }
  2069. };
  2070. window.GM_xmlhttpRequest(info);
  2071. }
  2072. else {
  2073. var client = application_1.Application.App.Client;
  2074. client.Recv(function (data) {
  2075. if (data.code == 0) {
  2076. if (info.json) {
  2077. if (HttpUtils.errorCode(data.body)) {
  2078. info.error && info.error();
  2079. return;
  2080. }
  2081. }
  2082. info.success && info.success(data.body);
  2083. }
  2084. else {
  2085. info.error && info.error();
  2086. }
  2087. });
  2088. client.Send({
  2089. type: "GM_xmlhttpRequest", info: {
  2090. url: info.url,
  2091. method: info.method,
  2092. json: info.json,
  2093. body: info.body,
  2094. headers: info.headers,
  2095. }
  2096. });
  2097. }
  2098. };
  2099. HttpUtils.HttpGet = function (url, info) {
  2100. info.url = url;
  2101. this.Request(info);
  2102. };
  2103. HttpUtils.HttpPost = function (url, body, info) {
  2104. info.url = url;
  2105. info.body = body;
  2106. if (!info.headers) {
  2107. info.headers = {};
  2108. }
  2109. if (!info.headers["Content-Type"]) {
  2110. info.headers["Content-Type"] = "application/x-www-form-urlencoded";
  2111. }
  2112. info.method = "POST";
  2113. this.Request(info);
  2114. };
  2115. HttpUtils.SendRequest = function (client, data) {
  2116. if (!data.info) {
  2117. return;
  2118. }
  2119. var info = data.info;
  2120. if (application_1.Application.App.IsBackend) {
  2121. info.success = function (body) {
  2122. client.Send({ body: body, code: 0 });
  2123. };
  2124. info.error = function () {
  2125. client.Send({ code: -1 });
  2126. };
  2127. HttpUtils.Request(info);
  2128. }
  2129. else {
  2130. // content 做转发
  2131. var extClient = application_1.Application.App.Client;
  2132. extClient.Send({ type: "GM_xmlhttpRequest", info: info });
  2133. extClient.Recv(function (data) {
  2134. client.Send(data);
  2135. });
  2136. }
  2137. };
  2138. return HttpUtils;
  2139. }());
  2140. exports.HttpUtils = HttpUtils;
  2141. /**
  2142. * 通过源码注入js资源
  2143. * @param doc
  2144. * @param url
  2145. * @constructor
  2146. */
  2147. function Injected(doc, source) {
  2148. var temp = doc.createElement('script');
  2149. temp.setAttribute('type', 'text/javascript');
  2150. temp.innerHTML = source;
  2151. temp.className = "injected-js";
  2152. doc.documentElement.appendChild(temp);
  2153. return temp;
  2154. }
  2155. exports.Injected = Injected;
  2156. /**
  2157. * 通过源码注入js资源
  2158. * @param doc
  2159. * @param url
  2160. * @constructor
  2161. */
  2162. function InjectedBySrc(doc, source) {
  2163. var temp = doc.createElement('script');
  2164. temp.setAttribute('type', 'text/javascript');
  2165. temp.src = source;
  2166. temp.className = "injected-js";
  2167. doc.documentElement.appendChild(temp);
  2168. return temp;
  2169. }
  2170. exports.InjectedBySrc = InjectedBySrc;
  2171. function syncGetChromeStorageLocal(key) {
  2172. return new Promise(function (resolve) { return (chrome.storage.local.get(key, function (value) {
  2173. resolve(value[key]);
  2174. })); });
  2175. }
  2176. exports.syncGetChromeStorageLocal = syncGetChromeStorageLocal;
  2177. function syncSetChromeStorageLocal(key, value) {
  2178. var tmp = {};
  2179. tmp[key] = value;
  2180. return new Promise(function (resolve) { return (chrome.storage.local.set(tmp, function () {
  2181. resolve();
  2182. })); });
  2183. }
  2184. exports.syncSetChromeStorageLocal = syncSetChromeStorageLocal;
  2185. /**
  2186. * 移除注入js
  2187. * @param doc
  2188. */
  2189. function RemoveInjected(doc) {
  2190. var resource = doc.getElementsByClassName("injected-js");
  2191. for (var i = 0; i < resource.length; i++) {
  2192. resource[i].remove();
  2193. }
  2194. }
  2195. exports.RemoveInjected = RemoveInjected;
  2196. function randNumber(minNum, maxNum) {
  2197. return Math.floor(Math.random() * (maxNum - minNum + 1) + minNum);
  2198. }
  2199. exports.randNumber = randNumber;
  2200. /**
  2201. * 创建一个按钮
  2202. * @param title
  2203. * @param description
  2204. * @param id
  2205. */
  2206. function createBtn(title, description, className, id) {
  2207. if (description === void 0) { description = ""; }
  2208. if (className === void 0) { className = ""; }
  2209. if (id === void 0) { id = ""; }
  2210. var btn = document.createElement('button');
  2211. btn.innerText = title;
  2212. btn.id = id;
  2213. btn.title = description;
  2214. btn.className = className;
  2215. return btn;
  2216. }
  2217. exports.createBtn = createBtn;
  2218. /**
  2219. * get请求
  2220. * @param {*} url
  2221. */
  2222. function get(url, success) {
  2223. var xmlhttp = createRequest();
  2224. xmlhttp.open("GET", url, true);
  2225. xmlhttp.onreadystatechange = function () {
  2226. if (this.readyState == 4) {
  2227. if (this.status == 200) {
  2228. success && success(this.responseText, this.resource);
  2229. }
  2230. else {
  2231. xmlhttp.errorCallback && xmlhttp.errorCallback(this);
  2232. }
  2233. }
  2234. };
  2235. xmlhttp.send();
  2236. return xmlhttp;
  2237. }
  2238. exports.get = get;
  2239. /**
  2240. * post请求
  2241. * @param {*} url
  2242. * @param {*} data
  2243. * @param {*} json
  2244. */
  2245. function post(url, data, json, success) {
  2246. if (json === void 0) { json = true; }
  2247. var xmlhttp = createRequest();
  2248. xmlhttp.open("POST", url, true);
  2249. if (json) {
  2250. xmlhttp.setRequestHeader("Content-Type", "application/json");
  2251. }
  2252. else {
  2253. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  2254. }
  2255. xmlhttp.onreadystatechange = function () {
  2256. if (this.readyState == 4) {
  2257. if (this.status == 200) {
  2258. success && success(this.responseText);
  2259. }
  2260. else {
  2261. xmlhttp.errorCallback && xmlhttp.errorCallback(this);
  2262. }
  2263. }
  2264. };
  2265. xmlhttp.send(data);
  2266. return xmlhttp;
  2267. }
  2268. exports.post = post;
  2269. /**
  2270. * 创建http请求
  2271. */
  2272. function createRequest() {
  2273. var xmlhttp;
  2274. if (window.XMLHttpRequest) {
  2275. xmlhttp = new XMLHttpRequest();
  2276. }
  2277. else {
  2278. xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  2279. }
  2280. xmlhttp.error = function (callback) {
  2281. xmlhttp.errorCallback = callback;
  2282. return xmlhttp;
  2283. };
  2284. xmlhttp.withCredentials = true;
  2285. return xmlhttp;
  2286. }
  2287. // 移除html tag
  2288. function removeHTMLTag(html) {
  2289. var revHtml = /<.*?>/g;
  2290. html = html.replace(revHtml, '');
  2291. html = html.replace(/(^\s+)|(\s+$)/g, '');
  2292. return html;
  2293. }
  2294. exports.removeHTMLTag = removeHTMLTag;
  2295. /**
  2296. * 去除html标签和处理中文
  2297. * @param {string} html
  2298. */
  2299. function removeHTML(html) {
  2300. //先处理带src和href属性的标签
  2301. var srcReplace = /<img.*?src="(.*?)".*?>/g;
  2302. html = html.replace(srcReplace, '$1');
  2303. srcReplace = /(<iframe.+?>)\s+?(<\/iframe>)/g;
  2304. html = html.replace(srcReplace, '$1$2');
  2305. srcReplace = /<(iframe|a).*?(src|href)="(.*?)".*?>(.*?)<\/(iframe|a)>/g;
  2306. html = html.replace(srcReplace, '$3$4');
  2307. var revHtml = /<.*?>/g;
  2308. html = html.replace(revHtml, '');
  2309. html = html.replace(/(^\s+)|(\s+$)/g, '');
  2310. html = dealSymbol(html);
  2311. return html.replace(/&nbsp;/g, ' ')
  2312. .replace(/&quot;/g, "\"").replace(/&gt;/g, ">")
  2313. .replace(/&lt;/g, "<").replace(/&amp;/g, '&').trim();
  2314. }
  2315. exports.removeHTML = removeHTML;
  2316. /**
  2317. * 处理符号
  2318. * @param topic
  2319. */
  2320. function dealSymbol(topic) {
  2321. topic = topic.replace(/,/g, ',');
  2322. topic = topic.replace(/(/g, '(');
  2323. topic = topic.replace(/)/g, ')');
  2324. topic = topic.replace(/?/g, '?');
  2325. topic = topic.replace(/:/g, ':');
  2326. topic = topic.replace(/。/g, '.');
  2327. topic = topic.replace(/[“”]/g, '"');
  2328. return topic;
  2329. }
  2330. /**
  2331. * 取中间文本
  2332. * @param str
  2333. * @param left
  2334. * @param right
  2335. */
  2336. function substrex(str, left, right) {
  2337. var leftPos = str.indexOf(left) + left.length;
  2338. var rightPos = str.indexOf(right, leftPos);
  2339. return str.substring(leftPos, rightPos);
  2340. }
  2341. exports.substrex = substrex;
  2342. function dealHotVersion(hotversion) {
  2343. hotversion = hotversion.substring(0, hotversion.indexOf(".") + 1) + hotversion.substring(hotversion.indexOf(".") + 1).replace(".", "");
  2344. return Number(hotversion);
  2345. }
  2346. exports.dealHotVersion = dealHotVersion;
  2347. function protocolPrompt(content, key, keyword) {
  2348. keyword = keyword || "yes";
  2349. if (localStorage[key] == undefined || localStorage[key] != 1) {
  2350. var msg = prompt(content + "\n如果以后不想再弹出本对话框并且同意请在下方填写\"" + keyword + "\"");
  2351. if (msg === null)
  2352. return false;
  2353. if (keyword != msg) {
  2354. return false;
  2355. }
  2356. localStorage[key] = 1;
  2357. }
  2358. return true;
  2359. }
  2360. exports.protocolPrompt = protocolPrompt;
  2361. function getImageBase64(img, ext) {
  2362. var canvas = document.createElement("canvas");
  2363. canvas.width = img.width;
  2364. canvas.height = img.height;
  2365. var ctx = canvas.getContext("2d");
  2366. ctx.drawImage(img, 0, 0, img.width, img.height);
  2367. var dataURL = canvas.toDataURL("image/" + ext, 0.75); //节省可怜的流量>_<,虽然好像没有啥
  2368. canvas = null;
  2369. return dataURL;
  2370. }
  2371. exports.getImageBase64 = getImageBase64;
  2372. function isPhone() {
  2373. return /Android|iPhone/i.test(navigator.userAgent);
  2374. }
  2375. exports.isPhone = isPhone;
  2376. function Noifications(details) {
  2377. if (window.hasOwnProperty("GM_notification")) {
  2378. window.GM_notification(details);
  2379. }
  2380. else {
  2381. var client = application_1.Application.App.Client;
  2382. client.Send({
  2383. type: "GM_notification", details: details,
  2384. });
  2385. application_1.Application.App.Client.Send(details);
  2386. }
  2387. }
  2388. exports.Noifications = Noifications;
  2389. function toBool(val) {
  2390. if (typeof val == "boolean") {
  2391. return val;
  2392. }
  2393. return val == "true";
  2394. }
  2395. exports.toBool = toBool;
  2396. function boolToString(val) {
  2397. if (val) {
  2398. return "true";
  2399. }
  2400. return "false";
  2401. }
  2402. exports.boolToString = boolToString;
  2403. function UntrustedClick(el) {
  2404. if (CAT_click != undefined) {
  2405. CAT_click(el);
  2406. return true;
  2407. }
  2408. var untrusted = new MouseEvent("click", { "clientX": 10086 });
  2409. if (!untrusted.isTrusted) {
  2410. application_1.Application.App.log.Warn("扩展执行错误");
  2411. return false;
  2412. }
  2413. return el.dispatchEvent(untrusted);
  2414. }
  2415. exports.UntrustedClick = UntrustedClick;
  2416. function Sleep(timeout) {
  2417. return new Promise(function (resolve) {
  2418. setTimeout(function () {
  2419. resolve(undefined);
  2420. }, timeout);
  2421. });
  2422. }
  2423. exports.Sleep = Sleep;
  2424.  
  2425.  
  2426. /***/ }),
  2427.  
  2428. /***/ "./src/mooc/chaoxing/utils.ts":
  2429. /*!************************************!*\
  2430. !*** ./src/mooc/chaoxing/utils.ts ***!
  2431. \************************************/
  2432. /*! no static exports found */
  2433. /***/ (function(module, exports, __webpack_require__) {
  2434.  
  2435. "use strict";
  2436.  
  2437. Object.defineProperty(exports, "__esModule", { value: true });
  2438. exports.CreateNoteLine = exports.CssBtn = void 0;
  2439. /**
  2440. * 美化按钮
  2441. */
  2442. function CssBtn(btn) {
  2443. btn.style.outline = 'none';
  2444. btn.style.border = '0';
  2445. btn.style.background = '#7d9d35';
  2446. btn.style.color = '#fff';
  2447. btn.style.borderRadius = '4px';
  2448. btn.style.padding = '2px 8px';
  2449. btn.style.cursor = 'pointer';
  2450. btn.style.fontSize = '12px';
  2451. btn.style.marginLeft = '4px';
  2452. btn.onmousemove = function () {
  2453. btn.style.boxShadow = '1px 1px 1px 1px #ccc';
  2454. };
  2455. btn.onmouseout = function () {
  2456. btn.style.boxShadow = '';
  2457. };
  2458. return btn;
  2459. }
  2460. exports.CssBtn = CssBtn;
  2461. function CreateNoteLine(text, label, append, after) {
  2462. var p = document.createElement("p");
  2463. p.style.color = "red";
  2464. p.style.fontSize = "14px";
  2465. p.className = "prompt-line-" + label;
  2466. p.innerHTML = text;
  2467. if (append != undefined) {
  2468. append.append(p);
  2469. }
  2470. if (after != undefined) {
  2471. after.after(p);
  2472. }
  2473. return p;
  2474. }
  2475. exports.CreateNoteLine = CreateNoteLine;
  2476.  
  2477.  
  2478. /***/ }),
  2479.  
  2480. /***/ "./src/mooc/course163/course163.ts":
  2481. /*!*****************************************!*\
  2482. !*** ./src/mooc/course163/course163.ts ***!
  2483. \*****************************************/
  2484. /*! no static exports found */
  2485. /***/ (function(module, exports, __webpack_require__) {
  2486.  
  2487. "use strict";
  2488.  
  2489. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  2490. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  2491. return new (P || (P = Promise))(function (resolve, reject) {
  2492. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  2493. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  2494. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  2495. step((generator = generator.apply(thisArg, _arguments || [])).next());
  2496. });
  2497. };
  2498. var __generator = (this && this.__generator) || function (thisArg, body) {
  2499. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  2500. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  2501. function verb(n) { return function (v) { return step([n, v]); }; }
  2502. function step(op) {
  2503. if (f) throw new TypeError("Generator is already executing.");
  2504. while (_) try {
  2505. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  2506. if (y = 0, t) op = [op[0] & 2, t.value];
  2507. switch (op[0]) {
  2508. case 0: case 1: t = op; break;
  2509. case 4: _.label++; return { value: op[1], done: false };
  2510. case 5: _.label++; y = op[1]; op = [0]; continue;
  2511. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  2512. default:
  2513. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  2514. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  2515. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  2516. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  2517. if (t[2]) _.ops.pop();
  2518. _.trys.pop(); continue;
  2519. }
  2520. op = body.call(thisArg, _);
  2521. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  2522. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  2523. }
  2524. };
  2525. Object.defineProperty(exports, "__esModule", { value: true });
  2526. exports.Course163 = void 0;
  2527. var hook_1 = __webpack_require__(/*! @App/internal/utils/hook */ "./src/internal/utils/hook.ts");
  2528. __webpack_require__(/*! ../../views/common */ "./src/views/common.ts");
  2529. var application_1 = __webpack_require__(/*! @App/internal/application */ "./src/internal/application.ts");
  2530. var task_1 = __webpack_require__(/*! @App/mooc/course163/task */ "./src/mooc/course163/task.ts");
  2531. var utils_1 = __webpack_require__(/*! @App/internal/utils/utils */ "./src/internal/utils/utils.ts");
  2532. var Course163 = /** @class */ (function () {
  2533. function Course163() {
  2534. }
  2535. Course163.prototype.Init = function () {
  2536. this.hookAjax();
  2537. };
  2538. Course163.prototype.hookAjax = function () {
  2539. var _this = this;
  2540. hook_1.Hook.HookAjaxRespond(["CourseBean.getLessonUnitLearnVo.dwr", "MocQuizBean.getQuizPaperDto.dwr", "PostBean.getPaginationReplys.dwr"], function (url, resp) {
  2541. var task = task_1.TaskFactory.CreateTask(url, resp);
  2542. if (task) {
  2543. setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
  2544. var _a, autonext;
  2545. var _this = this;
  2546. return __generator(this, function (_b) {
  2547. switch (_b.label) {
  2548. case 0:
  2549. clearInterval(this.delayTimer);
  2550. _a = this.lastTask;
  2551. if (!_a) return [3 /*break*/, 2];
  2552. return [4 /*yield*/, this.lastTask.Stop()];
  2553. case 1:
  2554. _a = (_b.sent());
  2555. _b.label = 2;
  2556. case 2:
  2557. _a;
  2558. this.lastTask = task;
  2559. this.lastTask.addEventListener("complete", function () {
  2560. _this.delay(function () { return __awaiter(_this, void 0, void 0, function () {
  2561. return __generator(this, function (_a) {
  2562. switch (_a.label) {
  2563. case 0: return [4 /*yield*/, this.lastTask.Submit()];
  2564. case 1:
  2565. _a.sent();
  2566. this.nextTask();
  2567. return [2 /*return*/];
  2568. }
  2569. });
  2570. }); });
  2571. });
  2572. return [4 /*yield*/, this.lastTask.Init()];
  2573. case 3:
  2574. _b.sent();
  2575. if (!application_1.Application.App.config.auto) return [3 /*break*/, 5];
  2576. autonext = document.querySelector(".j-autoNext");
  2577. if (autonext && autonext.checked) {
  2578. utils_1.UntrustedClick(autonext);
  2579. }
  2580. return [4 /*yield*/, this.lastTask.Start()];
  2581. case 4:
  2582. _b.sent();
  2583. _b.label = 5;
  2584. case 5: return [2 /*return*/];
  2585. }
  2586. });
  2587. }); }, 0);
  2588. }
  2589. return resp;
  2590. });
  2591. hook_1.Hook.HookAjaxRespond("MocQuizBean.fetchQuestions", function (url, resp) {
  2592. if (resp.indexOf("{questions:s0}") > 0) {
  2593. resp = resp.replace("{questions:s0}", "{questions:{}}");
  2594. }
  2595. return resp;
  2596. });
  2597. };
  2598. Course163.prototype.nextTask = function () {
  2599. var _this = this;
  2600. var unit = document.querySelectorAll(".j-unitslist.unitslist.f-cb > .f-fl");
  2601. var ret = this.next(unit, function (el) {
  2602. return el.className.indexOf("current") > 0;
  2603. });
  2604. if (ret) {
  2605. return utils_1.UntrustedClick(ret);
  2606. }
  2607. //二级
  2608. var tmp = function (type) {
  2609. var now = document.querySelector(".f-fl.j-" + type + " .up.j-up.f-thide");
  2610. var all = document.querySelectorAll(".f-fl.j-" + type + " .f-bg.j-list > .f-thide");
  2611. return _this.next(all, function (el) {
  2612. //什么魔鬼,空格不同
  2613. return el.innerText.replace(/\s/g, "") == now.innerText.replace(/\s/g, "");
  2614. });
  2615. };
  2616. ret = tmp("lesson");
  2617. if (ret) {
  2618. return utils_1.UntrustedClick(ret);
  2619. }
  2620. //顶层
  2621. ret = tmp("chapter");
  2622. if (ret) {
  2623. utils_1.UntrustedClick(ret);
  2624. var all = document.querySelectorAll(".f-fl.j-lesson .f-bg.j-list > .f-thide");
  2625. return utils_1.UntrustedClick(all[0]);
  2626. }
  2627. application_1.Application.App.log.Warn("任务结束了");
  2628. return alert("任务结束了");
  2629. };
  2630. Course163.prototype.next = function (all, ok) {
  2631. var flag = false;
  2632. for (var i = 0; i < all.length; i++) {
  2633. if (ok(all[i])) {
  2634. flag = true;
  2635. }
  2636. else if (flag) {
  2637. return all[i];
  2638. }
  2639. }
  2640. return null;
  2641. };
  2642. Course163.prototype.delay = function (func) {
  2643. var interval = application_1.Application.App.config.interval;
  2644. application_1.Application.App.log.Info(interval + "分钟后自动切换下一个任务点");
  2645. this.delayTimer = setTimeout(function () {
  2646. application_1.Application.App.config.auto && func();
  2647. }, interval * 60000);
  2648. };
  2649. return Course163;
  2650. }());
  2651. exports.Course163 = Course163;
  2652.  
  2653.  
  2654. /***/ }),
  2655.  
  2656. /***/ "./src/mooc/course163/platform.ts":
  2657. /*!****************************************!*\
  2658. !*** ./src/mooc/course163/platform.ts ***!
  2659. \****************************************/
  2660. /*! no static exports found */
  2661. /***/ (function(module, exports, __webpack_require__) {
  2662.  
  2663. "use strict";
  2664.  
  2665. Object.defineProperty(exports, "__esModule", { value: true });
  2666. exports.Course163Platform = void 0;
  2667. var course163_1 = __webpack_require__(/*! ./course163 */ "./src/mooc/course163/course163.ts");
  2668. var application_1 = __webpack_require__(/*! @App/internal/application */ "./src/internal/application.ts");
  2669. var Course163Platform = /** @class */ (function () {
  2670. function Course163Platform() {
  2671. }
  2672. Course163Platform.prototype.CreateMooc = function () {
  2673. if (document.URL.indexOf("www.icourse163.org") > 0) {
  2674. application_1.Application.App.config.SetNamespace("mooc163");
  2675. return new course163_1.Course163();
  2676. }
  2677. return null;
  2678. };
  2679. return Course163Platform;
  2680. }());
  2681. exports.Course163Platform = Course163Platform;
  2682.  
  2683.  
  2684. /***/ }),
  2685.  
  2686. /***/ "./src/mooc/course163/question.ts":
  2687. /*!****************************************!*\
  2688. !*** ./src/mooc/course163/question.ts ***!
  2689. \****************************************/
  2690. /*! no static exports found */
  2691. /***/ (function(module, exports, __webpack_require__) {
  2692.  
  2693. "use strict";
  2694.  
  2695. var __extends = (this && this.__extends) || (function () {
  2696. var extendStatics = function (d, b) {
  2697. extendStatics = Object.setPrototypeOf ||
  2698. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2699. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2700. return extendStatics(d, b);
  2701. };
  2702. return function (d, b) {
  2703. extendStatics(d, b);
  2704. function __() { this.constructor = d; }
  2705. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2706. };
  2707. })();
  2708. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  2709. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  2710. return new (P || (P = Promise))(function (resolve, reject) {
  2711. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  2712. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  2713. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  2714. step((generator = generator.apply(thisArg, _arguments || [])).next());
  2715. });
  2716. };
  2717. var __generator = (this && this.__generator) || function (thisArg, body) {
  2718. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  2719. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  2720. function verb(n) { return function (v) { return step([n, v]); }; }
  2721. function step(op) {
  2722. if (f) throw new TypeError("Generator is already executing.");
  2723. while (_) try {
  2724. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  2725. if (y = 0, t) op = [op[0] & 2, t.value];
  2726. switch (op[0]) {
  2727. case 0: case 1: t = op; break;
  2728. case 4: _.label++; return { value: op[1], done: false };
  2729. case 5: _.label++; y = op[1]; op = [0]; continue;
  2730. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  2731. default:
  2732. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  2733. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  2734. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  2735. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  2736. if (t[2]) _.ops.pop();
  2737. _.trys.pop(); continue;
  2738. }
  2739. op = body.call(thisArg, _);
  2740. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  2741. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  2742. }
  2743. };
  2744. Object.defineProperty(exports, "__esModule", { value: true });
  2745. exports.CourseTopic = exports.CourseQueryAnswer = void 0;
  2746. var topic_1 = __webpack_require__(/*! @App/internal/app/topic */ "./src/internal/app/topic.ts");
  2747. var question_1 = __webpack_require__(/*! @App/internal/app/question */ "./src/internal/app/question.ts");
  2748. var utils_1 = __webpack_require__(/*! ../chaoxing/utils */ "./src/mooc/chaoxing/utils.ts");
  2749. var utils_2 = __webpack_require__(/*! @App/internal/utils/utils */ "./src/internal/utils/utils.ts");
  2750. var application_1 = __webpack_require__(/*! @App/internal/application */ "./src/internal/application.ts");
  2751. var CourseQueryAnswer = /** @class */ (function () {
  2752. function CourseQueryAnswer() {
  2753. }
  2754. CourseQueryAnswer.prototype.QueryQuestions = function () {
  2755. var _this = this;
  2756. var ret = new Array();
  2757. var timu = document.querySelectorAll(".u-questionItem");
  2758. timu.forEach(function (val) {
  2759. ret.push(_this.createQuestion(val));
  2760. });
  2761. return ret;
  2762. };
  2763. CourseQueryAnswer.prototype.createQuestion = function (el) {
  2764. if (el.querySelector(".optionCnt span.u-icon-correct")) {
  2765. return new JudgeQuestion(el, 3);
  2766. }
  2767. else if (el.querySelector("input[type='radio']") != null) {
  2768. return new CourseQuestion(el, 1);
  2769. }
  2770. else if (el.querySelector("input[type='checkbox']") != null) {
  2771. return new CourseQuestion(el, 2);
  2772. }
  2773. else if (el.querySelector("textarea") != null) {
  2774. return new FillQuestion(el, 4);
  2775. }
  2776. return new CourseQuestion(el, -1);
  2777. };
  2778. return CourseQueryAnswer;
  2779. }());
  2780. exports.CourseQueryAnswer = CourseQueryAnswer;
  2781. //TODO:优化
  2782. var CourseQuestion = /** @class */ (function () {
  2783. function CourseQuestion(el, type) {
  2784. this.el = el;
  2785. this.type = type;
  2786. this.RemoveNotice();
  2787. }
  2788. CourseQuestion.prototype.GetType = function () {
  2789. return this.type;
  2790. };
  2791. CourseQuestion.prototype.GetTopic = function () {
  2792. return this.dealImgDomain(this.el.querySelector(".f-richEditorText.j-richTxt").innerHTML);
  2793. };
  2794. CourseQuestion.prototype.RemoveNotice = function () {
  2795. this.el.querySelectorAll(".prompt-line-answer").forEach(function (v) {
  2796. v.remove();
  2797. });
  2798. };
  2799. CourseQuestion.prototype.AddNotice = function (str) {
  2800. utils_1.CreateNoteLine(str, "answer", this.el);
  2801. };
  2802. CourseQuestion.prototype.SetStatus = function (status) {
  2803. this.AddNotice(question_1.TopicStatusString(status));
  2804. };
  2805. CourseQuestion.prototype.getContent = function (el) {
  2806. return el.querySelector(".f-fl.optionCnt").innerHTML;
  2807. };
  2808. CourseQuestion.prototype.getOption = function (el) {
  2809. return el.querySelector(".f-fl.optionPos").innerHTML.substring(0, 1);
  2810. };
  2811. CourseQuestion.prototype.fill = function (el, content) {
  2812. if (!el.parentElement.querySelector("input").checked) {
  2813. utils_2.UntrustedClick(el.parentElement.querySelector("input"));
  2814. }
  2815. content = content.replace(/style=".*?"/, "");
  2816. content = content.replace(/(<p>|<\/p>)/, "");
  2817. this.AddNotice(this.getOption(el) + ":" + content);
  2818. };
  2819. CourseQuestion.prototype.Random = function () {
  2820. var opts = this.options();
  2821. var pos = utils_2.randNumber(0, opts.length - 1);
  2822. this.fill(opts[pos], this.getContent(opts[pos - 1]));
  2823. return "random";
  2824. };
  2825. CourseQuestion.prototype.options = function () {
  2826. return this.el.querySelectorAll(".u-tbl.f-pr.f-cb");
  2827. };
  2828. CourseQuestion.prototype.dealImgDomain = function (content) {
  2829. //移除域名对比,也不知道还有没有花里胡哨的
  2830. content = content.replace(/"http(s|):\/\/edu-image.nosdn.127.net\/(.*?)"/, "\"http://nos.netease.com/edu-image/$2\"");
  2831. content = content.replace(/"http(s|):\/\/(.*?)\//g, "\"");
  2832. return content;
  2833. };
  2834. CourseQuestion.prototype.Fill = function (answer) {
  2835. var _this = this;
  2836. return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
  2837. var options, flag, i, n;
  2838. return __generator(this, function (_a) {
  2839. switch (_a.label) {
  2840. case 0:
  2841. options = this.options();
  2842. flag = false;
  2843. i = 0;
  2844. _a.label = 1;
  2845. case 1:
  2846. if (!(i < answer.correct.length)) return [3 /*break*/, 7];
  2847. n = 0;
  2848. _a.label = 2;
  2849. case 2:
  2850. if (!(n < options.length)) return [3 /*break*/, 6];
  2851. if (!answer.Equal(this.dealImgDomain(this.getContent(options[n])), this.dealImgDomain(answer.correct[i].content))) return [3 /*break*/, 5];
  2852. this.fill(options[n], answer.correct[i].content);
  2853. if (!(this.GetType() == 2 && i != answer.correct.length - 1)) return [3 /*break*/, 4];
  2854. //多选
  2855. return [4 /*yield*/, utils_2.Sleep(application_1.Application.App.config.topic_interval * 1000)];
  2856. case 3:
  2857. //多选
  2858. _a.sent();
  2859. _a.label = 4;
  2860. case 4:
  2861. flag = true;
  2862. _a.label = 5;
  2863. case 5:
  2864. n++;
  2865. return [3 /*break*/, 2];
  2866. case 6:
  2867. i++;
  2868. return [3 /*break*/, 1];
  2869. case 7:
  2870. if (flag) {
  2871. return [2 /*return*/, resolve("ok")];
  2872. }
  2873. return [2 /*return*/, resolve("no_match")];
  2874. }
  2875. });
  2876. }); });
  2877. };
  2878. CourseQuestion.prototype.Correct = function () {
  2879. return null;
  2880. };
  2881. return CourseQuestion;
  2882. }());
  2883. var FillQuestion = /** @class */ (function (_super) {
  2884. __extends(FillQuestion, _super);
  2885. function FillQuestion() {
  2886. return _super !== null && _super.apply(this, arguments) || this;
  2887. }
  2888. FillQuestion.prototype.Random = function () {
  2889. return "no_support_random";
  2890. };
  2891. FillQuestion.prototype.Fill = function (answer) {
  2892. var _this = this;
  2893. return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
  2894. var el, match;
  2895. return __generator(this, function (_a) {
  2896. el = this.el.querySelector("textarea");
  2897. el.focus();
  2898. if (match = answer.correct[0].content.match(/^[\(\[]([\d\.]+),([\d\.]+)[\)\]]$/)) {
  2899. //范围题
  2900. el.value = ((parseFloat(match[1]) + parseFloat(match[2])) / 2).toString();
  2901. this.AddNotice("填空 取值范围:" + answer.correct[0].content);
  2902. }
  2903. else {
  2904. el.value = answer.correct[0].content.split("##%_YZPRLFH_%##")[0];
  2905. this.AddNotice("填空:" + answer.correct[0].content.replace("##%_YZPRLFH_%##", " 或 "));
  2906. }
  2907. return [2 /*return*/, resolve("ok")];
  2908. });
  2909. }); });
  2910. };
  2911. return FillQuestion;
  2912. }(CourseQuestion));
  2913. var JudgeQuestion = /** @class */ (function (_super) {
  2914. __extends(JudgeQuestion, _super);
  2915. function JudgeQuestion() {
  2916. return _super !== null && _super.apply(this, arguments) || this;
  2917. }
  2918. JudgeQuestion.prototype.Fill = function (answer) {
  2919. var _this = this;
  2920. return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
  2921. var el;
  2922. return __generator(this, function (_a) {
  2923. if (answer.correct[0].content) {
  2924. el = this.el.querySelector(".u-tbl.f-pr.f-cb .u-icon-correct").parentElement.parentElement;
  2925. }
  2926. else {
  2927. el = this.el.querySelector(".u-tbl.f-pr.f-cb .u-icon-wrong").parentElement.parentElement;
  2928. }
  2929. this.fill(el, this.getContent(el));
  2930. return [2 /*return*/, resolve("ok")];
  2931. });
  2932. }); });
  2933. };
  2934. return JudgeQuestion;
  2935. }(CourseQuestion));
  2936. var CourseTopic = /** @class */ (function (_super) {
  2937. __extends(CourseTopic, _super);
  2938. function CourseTopic() {
  2939. return _super !== null && _super.apply(this, arguments) || this;
  2940. }
  2941. CourseTopic.prototype.Init = function () {
  2942. return null;
  2943. };
  2944. CourseTopic.prototype.Submit = function () {
  2945. return null;
  2946. };
  2947. return CourseTopic;
  2948. }(topic_1.Topic));
  2949. exports.CourseTopic = CourseTopic;
  2950.  
  2951.  
  2952. /***/ }),
  2953.  
  2954. /***/ "./src/mooc/course163/task.ts":
  2955. /*!************************************!*\
  2956. !*** ./src/mooc/course163/task.ts ***!
  2957. \************************************/
  2958. /*! no static exports found */
  2959. /***/ (function(module, exports, __webpack_require__) {
  2960.  
  2961. "use strict";
  2962.  
  2963. var __extends = (this && this.__extends) || (function () {
  2964. var extendStatics = function (d, b) {
  2965. extendStatics = Object.setPrototypeOf ||
  2966. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2967. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2968. return extendStatics(d, b);
  2969. };
  2970. return function (d, b) {
  2971. extendStatics(d, b);
  2972. function __() { this.constructor = d; }
  2973. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2974. };
  2975. })();
  2976. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  2977. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  2978. return new (P || (P = Promise))(function (resolve, reject) {
  2979. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  2980. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  2981. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  2982. step((generator = generator.apply(thisArg, _arguments || [])).next());
  2983. });
  2984. };
  2985. var __generator = (this && this.__generator) || function (thisArg, body) {
  2986. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  2987. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  2988. function verb(n) { return function (v) { return step([n, v]); }; }
  2989. function step(op) {
  2990. if (f) throw new TypeError("Generator is already executing.");
  2991. while (_) try {
  2992. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  2993. if (y = 0, t) op = [op[0] & 2, t.value];
  2994. switch (op[0]) {
  2995. case 0: case 1: t = op; break;
  2996. case 4: _.label++; return { value: op[1], done: false };
  2997. case 5: _.label++; y = op[1]; op = [0]; continue;
  2998. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  2999. default:
  3000. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  3001. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  3002. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  3003. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  3004. if (t[2]) _.ops.pop();
  3005. _.trys.pop(); continue;
  3006. }
  3007. op = body.call(thisArg, _);
  3008. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  3009. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  3010. }
  3011. };
  3012. Object.defineProperty(exports, "__esModule", { value: true });
  3013. exports.DiscussTask = exports.CourseTopicTask = exports.VideoTask = exports.NoSupportTask = exports.TaskFactory = void 0;
  3014. var task_1 = __webpack_require__(/*! @App/internal/app/task */ "./src/internal/app/task.ts");
  3015. var application_1 = __webpack_require__(/*! @App/internal/application */ "./src/internal/application.ts");
  3016. var utils_1 = __webpack_require__(/*! @App/internal/utils/utils */ "./src/internal/utils/utils.ts");
  3017. var question_1 = __webpack_require__(/*! @App/mooc/course163/question */ "./src/mooc/course163/question.ts");
  3018. var question_2 = __webpack_require__(/*! @App/internal/app/question */ "./src/internal/app/question.ts");
  3019. var TaskFactory = /** @class */ (function () {
  3020. function TaskFactory() {
  3021. }
  3022. TaskFactory.CreateTask = function (url, resp) {
  3023. if (resp.indexOf("paper:s") > 0) {
  3024. CourseTopicTask.collegeAnswer(this.getvalue(resp, resp.match(/,paper:(.*?),/)[1]));
  3025. return new CourseTopicTask();
  3026. }
  3027. else if (resp.indexOf("tname:\"") > 0) {
  3028. if (resp.indexOf("answers:s") > 0) {
  3029. CourseTopicTask.collegeAnswer(this.getvalue(resp, resp.match(/,objectiveQList:(.*?),/)[1]));
  3030. }
  3031. return new CourseTopicTask(resp);
  3032. }
  3033. else if (resp.indexOf("videoVo:s") > 0) {
  3034. return new VideoTask();
  3035. }
  3036. else if (resp.indexOf("list:s") > 0 && url.indexOf("PostBean.getPaginationReplys") > 0) {
  3037. return new DiscussTask(this.getvalue(resp, resp.match(/,list:(.*?),/)[1]));
  3038. }
  3039. else if (resp.indexOf(",post:s") > 0) {
  3040. return null;
  3041. }
  3042. return new NoSupportTask();
  3043. };
  3044. TaskFactory.getvalue = function (str, ret) {
  3045. try {
  3046. ret = ret || "s0";
  3047. var script = str.match(/^([\s\S]+?)dwr.engine._remoteHandleCallback/)[1];
  3048. script = "function a(){" + script + ";return " + ret + ";}a();";
  3049. return eval(script);
  3050. }
  3051. catch (e) {
  3052. application_1.Application.App.log.Error("获取题目发生了一个错误", e);
  3053. }
  3054. return null;
  3055. };
  3056. return TaskFactory;
  3057. }());
  3058. exports.TaskFactory = TaskFactory;
  3059. var NoSupportTask = /** @class */ (function (_super) {
  3060. __extends(NoSupportTask, _super);
  3061. function NoSupportTask() {
  3062. return _super !== null && _super.apply(this, arguments) || this;
  3063. }
  3064. NoSupportTask.prototype.Start = function () {
  3065. var _this = this;
  3066. return new Promise(function (resolve) {
  3067. resolve();
  3068. application_1.Application.App.log.Info("暂不支持的类型,跳过");
  3069. _this.callEvent("complete");
  3070. });
  3071. };
  3072. NoSupportTask.prototype.Done = function () {
  3073. return true;
  3074. };
  3075. NoSupportTask.prototype.Type = function () {
  3076. return "other";
  3077. };
  3078. return NoSupportTask;
  3079. }(task_1.Task));
  3080. exports.NoSupportTask = NoSupportTask;
  3081. var VideoTask = /** @class */ (function (_super) {
  3082. __extends(VideoTask, _super);
  3083. function VideoTask() {
  3084. return _super !== null && _super.apply(this, arguments) || this;
  3085. }
  3086. VideoTask.prototype.Init = function () {
  3087. var _this = this;
  3088. return new Promise(function (resolve) {
  3089. _this.timer = setInterval(function () {
  3090. var video = document.querySelector("video[id]");
  3091. if (video) {
  3092. clearInterval(_this.timer);
  3093. _this.video = video;
  3094. _this.video.addEventListener("loadstart", function () {
  3095. _this.initVideo();
  3096. });
  3097. _this.video.addEventListener("ended", function () {
  3098. _this.callEvent("complete");
  3099. });
  3100. _this.callEvent("load");
  3101. application_1.Application.App.log.Debug("视频加载完成");
  3102. resolve();
  3103. }
  3104. }, 500);
  3105. });
  3106. };
  3107. VideoTask.prototype.Done = function () {
  3108. return false;
  3109. };
  3110. VideoTask.prototype.Stop = function () {
  3111. var _this = this;
  3112. return new Promise(function (resolve) {
  3113. clearInterval(_this.timer);
  3114. _this.callEvent("stop");
  3115. resolve();
  3116. });
  3117. };
  3118. VideoTask.prototype.initVideo = function () {
  3119. this.video.muted = application_1.Application.App.config.video_mute;
  3120. if (application_1.Application.App.config.video_multiple > 1) {
  3121. this.video.playbackRate = application_1.Application.App.config.video_multiple;
  3122. }
  3123. };
  3124. VideoTask.prototype.Start = function () {
  3125. var _this = this;
  3126. return new Promise(function (resolve) {
  3127. _this.initVideo();
  3128. _this.video.play();
  3129. _this.timer = setInterval(function () {
  3130. application_1.Application.App.config.auto && _this.video.paused && _this.video.play();
  3131. }, 5000);
  3132. resolve();
  3133. });
  3134. };
  3135. VideoTask.prototype.Type = function () {
  3136. return "video";
  3137. };
  3138. return VideoTask;
  3139. }(task_1.Task));
  3140. exports.VideoTask = VideoTask;
  3141. var CourseTopicTask = /** @class */ (function (_super) {
  3142. __extends(CourseTopicTask, _super);
  3143. function CourseTopicTask(resp) {
  3144. var _this = _super.call(this) || this;
  3145. var info = "";
  3146. if (resp) {
  3147. info = utils_1.substrex(resp, ",{aid:", ",");
  3148. }
  3149. var prefix = "";
  3150. if (document.URL.indexOf("cid") > 0) {
  3151. prefix = "c-";
  3152. }
  3153. _this.bank = new question_2.ToolsQuestionBankFacade("mooc163", {
  3154. refer: document.URL,
  3155. id: prefix + CourseTopicTask.getid(),
  3156. info: info,
  3157. });
  3158. if (resp) {
  3159. _this.bank.CheckCourse();
  3160. }
  3161. return _this;
  3162. }
  3163. CourseTopicTask.getid = function () {
  3164. var id = document.URL.match(/(\?id|cid)=(.*?)($|&)/);
  3165. if (!id) {
  3166. id = document.URL.match(/(&id)=(.*?)$/);
  3167. }
  3168. if (!id) {
  3169. return "";
  3170. }
  3171. return id[2];
  3172. };
  3173. CourseTopicTask.collegeAnswer = function (resp) {
  3174. var id = this.getid();
  3175. if (id == "") {
  3176. return;
  3177. }
  3178. var prefix = "";
  3179. if (document.URL.indexOf("cid") > 0) {
  3180. prefix = "c-";
  3181. }
  3182. var bank = new question_2.ToolsQuestionBank("mooc163", {
  3183. refer: document.URL,
  3184. id: prefix + id,
  3185. });
  3186. var answer = new Array();
  3187. var options;
  3188. options = resp.objectiveQList;
  3189. if (options == undefined) {
  3190. options = resp;
  3191. }
  3192. if (options == undefined) {
  3193. return;
  3194. }
  3195. //TODO:优化,太难看了
  3196. for (var i = 0; i < options.length; i++) {
  3197. var topic = options[i];
  3198. if (topic.type != 1 && topic.type != 2) {
  3199. if (topic.type == 3) {
  3200. var tmpAnswer_1 = new question_2.PushAnswer();
  3201. tmpAnswer_1.topic = topic.title;
  3202. tmpAnswer_1.type = 4;
  3203. tmpAnswer_1.correct = new Array();
  3204. if (!topic.stdAnswer) {
  3205. continue;
  3206. }
  3207. tmpAnswer_1.correct.push({
  3208. option: "一", content: topic.stdAnswer,
  3209. });
  3210. answer.push(tmpAnswer_1);
  3211. }
  3212. else if (topic.type == 4) {
  3213. var tmpAnswer_2 = new question_2.PushAnswer();
  3214. tmpAnswer_2.topic = topic.title;
  3215. tmpAnswer_2.type = 3;
  3216. tmpAnswer_2.correct = new Array();
  3217. if (!topic.optionDtos) {
  3218. continue;
  3219. }
  3220. for (var n = 0; n < topic.optionDtos.length; n++) {
  3221. if (topic.optionDtos[n].answer) {
  3222. tmpAnswer_2.correct.push({
  3223. option: "正确" == topic.optionDtos[n].content,
  3224. content: "正确" == topic.optionDtos[n].content,
  3225. });
  3226. break;
  3227. }
  3228. }
  3229. answer.push(tmpAnswer_2);
  3230. }
  3231. continue;
  3232. }
  3233. if (!topic.optionDtos) {
  3234. continue;
  3235. }
  3236. var option = new Array();
  3237. var correct = new Array();
  3238. var tmpAnswer = new question_2.PushAnswer();
  3239. tmpAnswer.topic = topic.title;
  3240. tmpAnswer.type = topic.type;
  3241. for (var i_1 = 0; i_1 < topic.optionDtos.length; i_1++) {
  3242. var opt = { content: topic.optionDtos[i_1].content, option: String.fromCharCode(65 + i_1) };
  3243. if (topic.optionDtos[i_1].answer) {
  3244. correct.push(opt);
  3245. }
  3246. option.push(opt);
  3247. }
  3248. if (correct.length <= 0) {
  3249. return;
  3250. }
  3251. tmpAnswer.correct = correct;
  3252. tmpAnswer.answers = option;
  3253. answer.push(tmpAnswer);
  3254. }
  3255. bank.Push(answer);
  3256. };
  3257. CourseTopicTask.prototype.Init = function () {
  3258. var _this = this;
  3259. return new Promise(function (resolve) {
  3260. setTimeout(function () {
  3261. if (document.querySelector("#tools-search")) {
  3262. document.querySelector("#tools-search").remove();
  3263. }
  3264. var search = utils_1.createBtn("搜索答案", "点击搜索答案", "cx-btn mooc163-search", "tools-search");
  3265. var divel = document.querySelector(".j-unitct .m-learnunitUI");
  3266. if (!divel) {
  3267. divel = document.querySelector(".u-learn-moduletitle");
  3268. }
  3269. _this.topic = new question_1.CourseTopic(document, _this.bank);
  3270. _this.topic.SetQueryQuestions(new question_1.CourseQueryAnswer());
  3271. search.onclick = function () { return __awaiter(_this, void 0, void 0, function () {
  3272. var ret;
  3273. return __generator(this, function (_a) {
  3274. switch (_a.label) {
  3275. case 0:
  3276. search.innerText = "搜索中...";
  3277. return [4 /*yield*/, this.Start()];
  3278. case 1:
  3279. ret = _a.sent();
  3280. search.innerText = question_2.QuestionStatusString(ret);
  3281. return [2 /*return*/];
  3282. }
  3283. });
  3284. }); };
  3285. divel.insertBefore(search, divel.firstChild);
  3286. resolve();
  3287. }, 1000);
  3288. });
  3289. };
  3290. CourseTopicTask.prototype.Done = function () {
  3291. return false;
  3292. };
  3293. CourseTopicTask.prototype.Type = function () {
  3294. return "topic";
  3295. };
  3296. CourseTopicTask.prototype.Start = function () {
  3297. var _this = this;
  3298. return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
  3299. var ret;
  3300. return __generator(this, function (_a) {
  3301. switch (_a.label) {
  3302. case 0:
  3303. utils_1.protocolPrompt("你正准备使用中国慕课的答题功能,相应的我们需要你的正确答案,同意之后扩展将自动检索你的所有答案\n* 本项选择不会影响你的正常使用(协议当前版本有效)\n* 手动点击答题结果页面自动采集页面答案\n", "course_answer_collect_v2", "我同意");
  3304. return [4 /*yield*/, this.topic.QueryAnswer()];
  3305. case 1:
  3306. ret = _a.sent();
  3307. this.callEvent("complete");
  3308. resolve(ret);
  3309. return [2 /*return*/];
  3310. }
  3311. });
  3312. }); });
  3313. };
  3314. CourseTopicTask.prototype.Submit = function () {
  3315. return new Promise(function (resolve) {
  3316. var el = document.querySelector(".submit.j-submit");
  3317. if (el.style.display == "none") {
  3318. resolve();
  3319. }
  3320. utils_1.UntrustedClick(el);
  3321. var t = setInterval(function () {
  3322. var el = document.querySelector(".submit.j-replay");
  3323. if (el && el.style.display != "none") {
  3324. clearInterval(t);
  3325. resolve();
  3326. }
  3327. }, 1000);
  3328. });
  3329. };
  3330. return CourseTopicTask;
  3331. }(task_1.Task));
  3332. exports.CourseTopicTask = CourseTopicTask;
  3333. var DiscussTask = /** @class */ (function (_super) {
  3334. __extends(DiscussTask, _super);
  3335. function DiscussTask(resp) {
  3336. var _this = _super.call(this) || this;
  3337. _this.list = resp;
  3338. return _this;
  3339. }
  3340. DiscussTask.prototype.isRepeat = function () {
  3341. return document.querySelector("a.unfollowed") == undefined;
  3342. };
  3343. DiscussTask.prototype.Start = function () {
  3344. var _this = this;
  3345. if (!this.list && this.list.lenght <= 0) {
  3346. application_1.Application.App.log.Info("没有查询到记录,跳过");
  3347. this.callEvent("complete");
  3348. return;
  3349. }
  3350. if (this.isRepeat()) {
  3351. application_1.Application.App.log.Info("已经关注,跳过");
  3352. this.callEvent("complete");
  3353. return;
  3354. }
  3355. application_1.Application.App.log.Info("复读机开启,准备复读(回复当前本讨论)");
  3356. return new Promise(function (resolve) {
  3357. var num = 0;
  3358. var timer = setInterval(function () {
  3359. try {
  3360. var rand = _this.list[utils_1.randNumber(0, _this.list.length - 1)];
  3361. var el = document.querySelector("iframe[id*=ueditor_]");
  3362. application_1.Application.GlobalContext.UE.instants["ueditorInstant" + el.id.substr(el.id.indexOf("_") + 1)].setContent(rand.content);
  3363. }
  3364. catch (e) {
  3365. if (num < 5) {
  3366. return;
  3367. }
  3368. application_1.Application.App.log.Error("发生了错误,准备跳过", e);
  3369. }
  3370. clearInterval(timer);
  3371. _this.callEvent("complete");
  3372. resolve();
  3373. }, 1000);
  3374. });
  3375. };
  3376. DiscussTask.prototype.Done = function () {
  3377. return false;
  3378. };
  3379. DiscussTask.prototype.Type = function () {
  3380. return "other";
  3381. };
  3382. DiscussTask.prototype.Submit = function () {
  3383. if (this.isRepeat()) {
  3384. return;
  3385. }
  3386. return new Promise(function (resolve) {
  3387. application_1.Application.App.log.Info("准备提交");
  3388. var el = document.querySelector(".u-btn-sm.u-btn-primary");
  3389. if (!el) {
  3390. return resolve();
  3391. }
  3392. utils_1.UntrustedClick(el);
  3393. setTimeout(function () {
  3394. resolve();
  3395. }, 2000);
  3396. });
  3397. };
  3398. return DiscussTask;
  3399. }(task_1.Task));
  3400. exports.DiscussTask = DiscussTask;
  3401.  
  3402.  
  3403. /***/ }),
  3404.  
  3405. /***/ "./src/mooc/mooc.ts":
  3406. /*!**************************!*\
  3407. !*** ./src/mooc/mooc.ts ***!
  3408. \**************************/
  3409. /*! no static exports found */
  3410. /***/ (function(module, exports, __webpack_require__) {
  3411.  
  3412. "use strict";
  3413.  
  3414. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  3415. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  3416. return new (P || (P = Promise))(function (resolve, reject) {
  3417. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  3418. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  3419. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  3420. step((generator = generator.apply(thisArg, _arguments || [])).next());
  3421. });
  3422. };
  3423. var __generator = (this && this.__generator) || function (thisArg, body) {
  3424. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  3425. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  3426. function verb(n) { return function (v) { return step([n, v]); }; }
  3427. function step(op) {
  3428. if (f) throw new TypeError("Generator is already executing.");
  3429. while (_) try {
  3430. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  3431. if (y = 0, t) op = [op[0] & 2, t.value];
  3432. switch (op[0]) {
  3433. case 0: case 1: t = op; break;
  3434. case 4: _.label++; return { value: op[1], done: false };
  3435. case 5: _.label++; y = op[1]; op = [0]; continue;
  3436. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  3437. default:
  3438. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  3439. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  3440. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  3441. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  3442. if (t[2]) _.ops.pop();
  3443. _.trys.pop(); continue;
  3444. }
  3445. op = body.call(thisArg, _);
  3446. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  3447. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  3448. }
  3449. };
  3450. Object.defineProperty(exports, "__esModule", { value: true });
  3451. exports.mooc = void 0;
  3452. var application_1 = __webpack_require__(/*! @App/internal/application */ "./src/internal/application.ts");
  3453. var mooc = /** @class */ (function () {
  3454. function mooc(moocFactory) {
  3455. // 防止taskComplete和reload冲突
  3456. this.once = false;
  3457. this.moocFactory = moocFactory;
  3458. }
  3459. mooc.prototype.start = function () {
  3460. return __awaiter(this, void 0, void 0, function () {
  3461. var state, mooc_1, e_1, isShow_1;
  3462. return __generator(this, function (_a) {
  3463. switch (_a.label) {
  3464. case 0:
  3465. _a.trys.push([0, 3, , 4]);
  3466. state = document.readyState;
  3467. application_1.Application.App.log.Debug("Start document state:", state);
  3468. mooc_1 = this.moocFactory.CreateMooc();
  3469. if (!(mooc_1 != null)) return [3 /*break*/, 2];
  3470. return [4 /*yield*/, mooc_1.Init()];
  3471. case 1:
  3472. _a.sent();
  3473. // MoocTaskSet接口判断,接管流程
  3474. if (mooc_1.Next != undefined) {
  3475. this.runMoocTask(mooc_1);
  3476. }
  3477. _a.label = 2;
  3478. case 2: return [3 /*break*/, 4];
  3479. case 3:
  3480. e_1 = _a.sent();
  3481. application_1.Application.App.log.Fatal("扩展发生了一个致命错误:", e_1);
  3482. return [3 /*break*/, 4];
  3483. case 4:
  3484. //最小化警告
  3485. if (top == self) {
  3486. isShow_1 = false;
  3487. document.addEventListener("visibilitychange", function () {
  3488. if (document.hidden) {
  3489. if (isShow_1) {
  3490. return;
  3491. }
  3492. application_1.Application.App.log.Warn("请注意!最小化可能导致视频无法正常播放!允许切换窗口.");
  3493. isShow_1 = true;
  3494. }
  3495. });
  3496. }
  3497. return [2 /*return*/];
  3498. }
  3499. });
  3500. });
  3501. };
  3502. mooc.prototype.runMoocTask = function (moocTask) {
  3503. var _this = this;
  3504. moocTask.addEventListener("reload", function () {
  3505. if (application_1.Application.App.config.auto) {
  3506. _this.runTask(moocTask);
  3507. }
  3508. clearTimeout(_this.timer);
  3509. });
  3510. moocTask.addEventListener("complete", function () {
  3511. application_1.Application.App.log.Warn("任务完成了");
  3512. alert("任务完成了");
  3513. });
  3514. moocTask.addEventListener("taskComplete", function (index, task) {
  3515. moocTask.SetTaskPointer(index + 1);
  3516. if (!application_1.Application.App.config.auto) {
  3517. return;
  3518. }
  3519. var interval = application_1.Application.App.config.interval;
  3520. application_1.Application.App.log.Info(interval + "分钟后自动切换下一个任务点");
  3521. _this.timer = setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
  3522. return __generator(this, function (_a) {
  3523. switch (_a.label) {
  3524. case 0: return [4 /*yield*/, task.Submit()];
  3525. case 1:
  3526. _a.sent();
  3527. return [4 /*yield*/, this.runTask(moocTask)];
  3528. case 2:
  3529. _a.sent();
  3530. return [2 /*return*/];
  3531. }
  3532. });
  3533. }); }, interval * 60000);
  3534. });
  3535. moocTask.addEventListener("error", function (msg) {
  3536. application_1.Application.App.log.Fatal(msg);
  3537. alert(msg);
  3538. });
  3539. };
  3540. mooc.prototype.runTask = function (moocTask) {
  3541. return __awaiter(this, void 0, void 0, function () {
  3542. var task;
  3543. return __generator(this, function (_a) {
  3544. switch (_a.label) {
  3545. case 0:
  3546. if (this.once) {
  3547. return [2 /*return*/];
  3548. }
  3549. this.once = true;
  3550. return [4 /*yield*/, moocTask.Next()];
  3551. case 1:
  3552. task = _a.sent();
  3553. _a.label = 2;
  3554. case 2:
  3555. if (!(task != null)) return [3 /*break*/, 9];
  3556. if (!task.Done()) return [3 /*break*/, 4];
  3557. return [4 /*yield*/, moocTask.Next()];
  3558. case 3:
  3559. task = _a.sent();
  3560. return [3 /*break*/, 2];
  3561. case 4:
  3562. if (!(application_1.Application.App.config.answer_ignore && task.Type() == "topic")) return [3 /*break*/, 6];
  3563. return [4 /*yield*/, moocTask.Next()];
  3564. case 5:
  3565. task = _a.sent();
  3566. return [3 /*break*/, 2];
  3567. case 6:
  3568. if (!application_1.Application.App.config.auto) return [3 /*break*/, 8];
  3569. return [4 /*yield*/, task.Start()];
  3570. case 7:
  3571. _a.sent();
  3572. _a.label = 8;
  3573. case 8:
  3574. this.nowTask = task;
  3575. return [3 /*break*/, 9];
  3576. case 9:
  3577. this.once = false;
  3578. return [2 /*return*/];
  3579. }
  3580. });
  3581. });
  3582. };
  3583. return mooc;
  3584. }());
  3585. exports.mooc = mooc;
  3586.  
  3587.  
  3588. /***/ }),
  3589.  
  3590. /***/ "./src/tampermonkey/course163-pack.ts":
  3591. /*!********************************************!*\
  3592. !*** ./src/tampermonkey/course163-pack.ts ***!
  3593. \********************************************/
  3594. /*! no static exports found */
  3595. /***/ (function(module, exports, __webpack_require__) {
  3596.  
  3597. "use strict";
  3598.  
  3599. Object.defineProperty(exports, "__esModule", { value: true });
  3600. var config_1 = __webpack_require__(/*! @App/internal/utils/config */ "./src/internal/utils/config.ts");
  3601. var log_1 = __webpack_require__(/*! @App/internal/utils/log */ "./src/internal/utils/log.ts");
  3602. var application_1 = __webpack_require__(/*! @App/internal/application */ "./src/internal/application.ts");
  3603. var mooc_1 = __webpack_require__(/*! @App/mooc/mooc */ "./src/mooc/mooc.ts");
  3604. var platform_1 = __webpack_require__(/*! @App/mooc/course163/platform */ "./src/mooc/course163/platform.ts");
  3605. var logger;
  3606. if (top == self) {
  3607. logger = new log_1.PageLog();
  3608. }
  3609. else {
  3610. logger = new log_1.ConsoleLog();
  3611. }
  3612. application_1.Application.GlobalContext = window.unsafeWindow;
  3613. var component = new Map().
  3614. set("config", new config_1.ChromeConfigItems(config_1.NewFrontendGetConfig())).
  3615. set("logger", logger);
  3616. var app = new application_1.Application(application_1.Frontend, new mooc_1.mooc(new platform_1.Course163Platform()), component);
  3617. app.run();
  3618.  
  3619.  
  3620. /***/ }),
  3621.  
  3622. /***/ "./src/views/common.ts":
  3623. /*!*****************************!*\
  3624. !*** ./src/views/common.ts ***!
  3625. \*****************************/
  3626. /*! no static exports found */
  3627. /***/ (function(module, exports) {
  3628.  
  3629. window.addEventListener("load", function () {
  3630. var css = "\n@keyframes aniripple \n{\n 0%{\n width:0px;\n height:0px;\n opacity:0.4;\n }\n 100%{\n width:500px;\n height:500px;\n opacity:0;\n }\n} \n\n#cxtools {\n position: absolute;\n left: 250px;\n top: 2px;\n width: 210px;\n font-size: 0;\n}\n\n.cx-btn {\n outline: none;\n border: 0;\n background: #7d9d35;\n color: #fff;\n border-radius: 4px;\n padding: 2px 8px;\n cursor: pointer;\n font-size: 12px;\n margin-left: 4px;\n}\n\n.cx-btn:hover {\n box-shadow: 1px 1px 1px 1px #ccc;\n}\n\n.zhs-tools-btn {\n color: #fff;\n background: #ff9d34;\n padding: 4px;\n display: inline-block;\n height: 24px;\n font-size: 14px;\n line-height: 24px;\n margin:0;\n cursor:pointer;\n}\n.btn-ripple{\n position:absolute;\n background:#000;\n pointer-events:none;\n transform:translate(-50%,-50%);\n border-radius:50%;\n animation:aniripple 1s linear infinite;\n}\n\n.zhs-start-btn{\n background: #36ac36;\n}\n\n.zhs-start-btn:hover{\n background: #3b8d3b;\n}\n\n#zhs-ytbn {\n color: #fff;\n background: #e777ff;\n}\n\n#zhs-ytbn:hover {\n background: #e7b7f1;\n}\n\n.zhs-search-answer {\n border: 0;\n outline: none;\n padding: 4px;\n}\n\n.zhs-search-answer:hover {\n opacity: .85;\n}\n\n.mooc163-search{\n background-color: #60b900;\n display: block;\n margin: 0 auto;\n}\n\n.tools-logger-panel{\n width: 360px;\n height: auto;\n max-height: 260px;\n color:#000;\n position: fixed;\n margin: 0 auto;\n display: block;\n font-size: 14px;\n border-radius: 4px;\n width: 340px;\n text-align: center;\n overflow: hidden;\n left:60px;\n top: 40px;\n z-index: 100000;\n background: rgba(256, 256, 256, 0.3);\n box-shadow: 0px 0px 5px #bbb;\n}\n\n.head {\n width: 100%;\n height: 30px;\n padding: 4px;\n box-sizing: border-box;\n cursor: move;\n transition-property: opacity, background-color;\n transition: 200ms ease-in-out;\n}\n\n.head span{\n color:#000;\n float:left;\n font-weight: 550;\n}\n\n.status {\n color: #67C23A;\n font-weight: 600;\n}\n\n.tools-notice-content {\n width: 100%;\n height: 220px;\n border-top:0px;\n overflow-y: scroll;\n overflow-x: hidden;\n}\n\n.tools-notice-content .log {\n height: auto;\n width: auto;\n text-align: center;\n border: 1px solid #eee;\n overflow: hidden;\n}\n\n.tools-notice-content .log p {\n margin: 0;\n color: #aaa;\n font-size: 11px;\n font-weight: 500;\n font-family: Arial, Helvetica, sans-serif;\n line-height: 26px;\n}\n\n/* \u6EDA\u52A8\u69FD */\n::-webkit-scrollbar {\n width: 10px;\n height: 10px;\n}\n\n::-webkit-scrollbar-track {\n border-radius: 3px;\n background: rgba(0, 0, 0, 0.06);\n -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.08);\n}\n\n/* \u6EDA\u52A8\u6761\u6ED1\u5757 */\n::-webkit-scrollbar-thumb {\n border-radius: 3px;\n background: rgba(0, 0, 0, 0.12);\n -webkit-box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2);\n}\n\n/* \u590D\u9009\u6846 */\n.switch {\n margin: 2px auto;\n display: inline-flex;\n align-items: center;\n width: auto;\n}\n.checkbox-input {\n display: none\n}\n.checkbox {\n -webkit-transition: background-color 0.3s;\n transition: background-color 0.3s;\n background-color: #fff;\n border: 1px solid #d7d7d7;\n border-radius: 50px;\n width: 16px;\n height: 16px;\n vertical-align:middle;\n margin: 0 5px;\n}\n.checkbox-input:checked+.checkbox {\n background-color: #409EFF;\n}\n.checkbox-input:checked+.checkbox:after {\n // content: \"\u221A\";\n display: inline-block;\n height: 100%;\n width: 100%;\n color: #fff;\n text-align: center;\n line-height: 16px;\n font-size: 12px;\n box-shadow: 0 0 4px #409EFF;\n}\n\n.tools-logger-panel:hover,\n.tools-logger-panel:focus-within {\n background: rgba(256, 256, 256, 0.7);\n}\n\n.tools-logger-panel .head:active {\n background-color: #E5E5E5;\n}\n\n.tools-logger-panel > .close {\n margin: 2px;\n}\n\n";
  3631. var style = document.createElement("style");
  3632. style.innerHTML = css;
  3633. document.body.appendChild(style);
  3634. });
  3635.  
  3636.  
  3637. /***/ })
  3638.  
  3639. /******/ });
  3640. //# sourceMappingURL=tampermonkey-course163.js.map

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址