网课全助手|自动挂机|视频文档|章节测验|专业课满分|超高倍速|防清进度

支持【超星学习通】【智慧树】【职教云系列】【雨课堂】【考试星】【168网校】【u校园】【大学MOOC】【云班课】【优慕课】【继续教育类】【绎通云课堂】【九江系列】【柠檬文才】【亿学宝云】【优课学堂】【小鹅通】【安徽继续教育】【上海开放大学】【华侨大学自考网络助学平台】【良师在线】【和学在线】【人卫慕课】【国家开放大学】【山财培训网】【浙江省高等学校在线开放课程共享平台】【重庆大学网络教育学院】【浙江省高等教育自学考试网络助学平台】【湖南高等学历继续教育】【优学院】【学起系列】【青书学堂】【学堂在线】【英华学堂】【广开网络教学平台】等,内置题库功能。如您遇到问题,请联系 Q群: 692178019邀请码为6666 系统兼容多种学习平台,支持一键搜题,提升学习效率。新增AI搜题、(如ChatGPT)技术,打破不可复制文本限制。,脚本不收集任何个人信息,确保用户隐私安全。无论是学习、复习备考,还是在线课程,本系统都能提供有效支持,使学习高效轻松。使用本系统,您将能够获取所需学习资源,提升学习效率,取得更好成绩。部分收费是为了维护脚本的运作。感谢您对本系统的信任与支持

目前为 2024-12-21 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name 网课全助手|自动挂机|视频文档|章节测验|专业课满分|超高倍速|防清进度
  3. // @version 1.21
  4. // @description 支持【超星学习通】【智慧树】【职教云系列】【雨课堂】【考试星】【168网校】【u校园】【大学MOOC】【云班课】【优慕课】【继续教育类】【绎通云课堂】【九江系列】【柠檬文才】【亿学宝云】【优课学堂】【小鹅通】【安徽继续教育】【上海开放大学】【华侨大学自考网络助学平台】【良师在线】【和学在线】【人卫慕课】【国家开放大学】【山财培训网】【浙江省高等学校在线开放课程共享平台】【重庆大学网络教育学院】【浙江省高等教育自学考试网络助学平台】【湖南高等学历继续教育】【优学院】【学起系列】【青书学堂】【学堂在线】【英华学堂】【广开网络教学平台】等,内置题库功能。如您遇到问题,请联系 Q群: 692178019邀请码为6666 系统兼容多种学习平台,支持一键搜题,提升学习效率。新增AI搜题、(如ChatGPT)技术,打破不可复制文本限制。,脚本不收集任何个人信息,确保用户隐私安全。无论是学习、复习备考,还是在线课程,本系统都能提供有效支持,使学习高效轻松。使用本系统,您将能够获取所需学习资源,提升学习效率,取得更好成绩。部分收费是为了维护脚本的运作。感谢您对本系统的信任与支持
  5. // @author mianbaolo
  6. // @namespace https://a.pengzi.cc/
  7. // @icon https://a.pengzi.cc/assets/images/2.webp
  8. // @author CodFrm
  9. // @run-at document-start
  10. // @match *://*.mosoteach.cn/*
  11. // @match *://*.chaoxing.com/*
  12. // @match *://*.xueyinonline.com/*
  13. // @match *://*.edu.cn/*
  14. // @match *://*.ouchn.cn/*
  15. // @match *://*.nbdlib.cn/*
  16. // @match *://*.hnsyu.net/*
  17. // @match *://*.gdhkmooc.com/*
  18. // @match *://*.zhihuishu.com/*
  19. // @match *://*.icve.com.cn/*
  20. // @match *://*.yuketang.cn/*
  21. // @match *://v.met0.top/*
  22. // @match *://*.icourse163.org/*
  23. // @match *://*.xuetangx.com/*
  24. // @match *://*/mycourse/studentstudy?*
  25. // @match *://*/ztnodedetailcontroller/visitnodedetail?*
  26. // @match *://*/antispiderShowVerify.ac*
  27. // @match *://*/html/processVerify.ac?*
  28. // @match *://*/exam/test/reVersionPaperMarkContentNew?*
  29. // @match *://*/exam/test/reVersionTestStartNew?*
  30. // @match *://*/work/selectWorkQuestionYiPiYue?*
  31. // @match *://*/work/doHomeWorkNew?*
  32. // @match *://*/ananas/modules/*/index.html?*
  33. // @match *://*/exam/test?*
  34. // @match *://*/course/*.html?*
  35. // @match *://*.chaoxing.com/
  36. // @match *://*.zhihuishu.com/
  37. // @match *://*.chaoxing.com/work/doHomeWorkNew*
  38. // @match *://*.chaoxing.com/mooc-ans/work/doHomeWorkNew*
  39. // @match *://*.edu.cn/work/doHomeWorkNew*
  40. // @match *://*.edu.cn/mooc-ans/work/doHomeWorkNew*
  41. // @grant GM_xmlhttpRequest
  42. // @grant GM_notification
  43. // @grant unsafeWindow
  44. // @resource Table https://www.forestpolice.org/ttf/2.0/table.json
  45. // @run-at document-end
  46. // @grant GM_getResourceText
  47. // @license MIT
  48. // @supportURL https://bbs.tampermonkey.net.cn/forum.php?mod=viewthread&tid=63
  49. // @homepage https://bbs.tampermonkey.net.cn/forum.php?mod=viewthread&tid=63
  50. // @antifeature membership
  51. // @antifeature ads
  52.  
  53. // ==/UserScript==
  54. let config = {
  55. answer_ignore: false, //忽略题目,勾选此处将不会答题
  56. auto: true, //全自动挂机,无需手动操作,即可自动观看视频等
  57. interval: 0.5, //时间间隔,当任务点完成后,会等待1分钟然后跳转到下一个任务点
  58. rand_answer: false, //随机答案,没有答案的题目将自动的生成一个答案
  59. video_multiple: 1, //视频播放倍速,视频播放的倍数,建议不要改动,为1即可,这是危险的功能
  60. video_mute: true, //视频静音,视频自动静音播放
  61. video_cdn: "公网1", //锁定视频播放源,为空为记录最后一次选中的源(公网1,公网2等)
  62. super_mode: true, //解锁flash弹幕视频等,详情请看文档
  63. topic_interval: 5,//题目答题间隔,单位为秒
  64. vtoken: "",
  65. };
  66. Object.keys(config).forEach(k => {
  67. localStorage[k] = config[k];
  68. });
  69. /******/ (function(modules) { // webpackBootstrap
  70. /******/ // The module cache
  71. /******/ var installedModules = {};
  72. /******/
  73. /******/ // The require function
  74. /******/ function __webpack_require__(moduleId) {
  75. /******/
  76. /******/ // Check if module is in cache
  77. /******/ if(installedModules[moduleId]) {
  78. /******/ return installedModules[moduleId].exports;
  79. /******/ }
  80. /******/ // Create a new module (and put it into the cache)
  81. /******/ var module = installedModules[moduleId] = {
  82. /******/ i: moduleId,
  83. /******/ l: false,
  84. /******/ exports: {}
  85. /******/ };
  86. /******/
  87. /******/ // Execute the module function
  88. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  89. /******/
  90. /******/ // Flag the module as loaded
  91. /******/ module.l = true;
  92. /******/
  93. /******/ // Return the exports of the module
  94. /******/ return module.exports;
  95. /******/ }
  96. /******/
  97. /******/
  98. /******/ // expose the modules object (__webpack_modules__)
  99. /******/ __webpack_require__.m = modules;
  100. /******/
  101. /******/ // expose the module cache
  102. /******/ __webpack_require__.c = installedModules;
  103. /******/
  104. /******/ // define getter function for harmony exports
  105. /******/ __webpack_require__.d = function(exports, name, getter) {
  106. /******/ if(!__webpack_require__.o(exports, name)) {
  107. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  108. /******/ }
  109. /******/ };
  110. /******/
  111. /******/ // define __esModule on exports
  112. /******/ __webpack_require__.r = function(exports) {
  113. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  114. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  115. /******/ }
  116. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  117. /******/ };
  118. /******/
  119. /******/ // create a fake namespace object
  120. /******/ // mode & 1: value is a module id, require it
  121. /******/ // mode & 2: merge all properties of value into the ns
  122. /******/ // mode & 4: return value when already ns object
  123. /******/ // mode & 8|1: behave like require
  124. /******/ __webpack_require__.t = function(value, mode) {
  125. /******/ if(mode & 1) value = __webpack_require__(value);
  126. /******/ if(mode & 8) return value;
  127. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  128. /******/ var ns = Object.create(null);
  129. /******/ __webpack_require__.r(ns);
  130. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  131. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  132. /******/ return ns;
  133. /******/ };
  134. /******/
  135. /******/ // getDefaultExport function for compatibility with non-harmony modules
  136. /******/ __webpack_require__.n = function(module) {
  137. /******/ var getter = module && module.__esModule ?
  138. /******/ function getDefault() { return module['default']; } :
  139. /******/ function getModuleExports() { return module; };
  140. /******/ __webpack_require__.d(getter, 'a', getter);
  141. /******/ return getter;
  142. /******/ };
  143. /******/
  144. /******/ // Object.prototype.hasOwnProperty.call
  145. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  146. /******/
  147. /******/ // __webpack_public_path__
  148. /******/ __webpack_require__.p = "";
  149. /******/
  150. /******/
  151. /******/ // Load entry module and return exports
  152. /******/ return __webpack_require__(__webpack_require__.s = "./src/tampermonkey/cxmooc-pack.ts");
  153. /******/ })
  154. /************************************************************************/
  155. /******/ ({
  156. /***/ "./src/config.ts":
  157. /*!***********************!*\
  158. !*** ./src/config.ts ***!
  159. \***********************/
  160. /*! no static exports found */
  161. /***/ (function(module, exports, __webpack_require__) {
  162. "use strict";
  163. Object.defineProperty(exports, "__esModule", { value: true });
  164. exports.SystemConfig = void 0;
  165. var SystemConfig = /** @class */ (function () {
  166. function SystemConfig() {
  167. }
  168. SystemConfig.version = 2.5;
  169. SystemConfig.url = "";
  170. SystemConfig.hotVersion = "2.5.2";
  171. //TODO:优化规则,可以通过ci自动生成匹配规则到tampermonkey和manifest文件中
  172. SystemConfig.match = {
  173. "cx": [
  174. "*://*/mycourse/studentstudy?*",
  175. "*://*/work/doHomeWorkNew?*",
  176. "*://*/work/selectWorkQuestionYiPiYue?*",
  177. "*://*/exam/test/reVersionTestStartNew?*",
  178. "*://*/ztnodedetailcontroller/visitnodedetail?*",
  179. "*://*/antispiderShowVerify.ac*",
  180. "*://*/html/processVerify.ac?*",
  181. "*://*/exam/test/reVersionPaperMarkContentNew?*",
  182. "*://*/ananas/modules/*/index.html?*",
  183. "*://*/exam/test?*",
  184. "*://*/course/*.html?*"
  185. ], "zhs": [
  186. "*://examh5.zhihuishu.com/stuExamWeb.html*",
  187. "*://onlineexamh5new.zhihuishu.com/stuExamWeb.html*",
  188. "*://studyh5.zhihuishu.com/videoStudy.html*",
  189. ], "mooc163": [
  190. "*://www.icourse163.org/learn/*",
  191. "*://www.icourse163.org/spoc/learn/*"
  192. ]
  193. };
  194. SystemConfig.config = {
  195. cx: {
  196. name: "超星",
  197. items: [{
  198. title: "随机答案",
  199. description: "如果题库没有正确的答案会随机选择",
  200. type: "checkbox",
  201. key: "rand_answer",
  202. value: false,
  203. }, {
  204. title: "自动挂机",
  205. description: "进入一个页面就会自动开始挂机,完成一个任务之后会自动进行下一个",
  206. type: "checkbox",
  207. key: "auto",
  208. value: true,
  209. }, {
  210. title: "视频静音",
  211. description: "播放视频时,自动开启静音",
  212. type: "checkbox",
  213. key: "video_mute",
  214. value: true,
  215. }, {
  216. title: "忽略题目",
  217. description: "自动挂机时,忽略掉题目不做,直接跳过",
  218. type: "checkbox",
  219. key: "answer_ignore",
  220. value: false,
  221. }, {
  222. title: "超级模式",
  223. description: "超星平台下,超级模式会自动将flash播放器换成h5播放器",
  224. type: "checkbox",
  225. key: "super_mode",
  226. value: true,
  227. }, {
  228. title: "播放源",
  229. description: "锁定视频播放源,为空为记录最后一次选中的源(公网1,公网2等)",
  230. type: "text",
  231. key: "video_cdn",
  232. value: "默认"
  233. }, {
  234. title: "播放倍速",
  235. description: "视频播放的倍数,1为正常速度(最高16倍,该功能有一定危险)",
  236. type: "text",
  237. key: "video_multiple",
  238. prompt: "这是一个很危险的功能,建议不要进行调整,如果你想调整播放速度请在下方填写yes(智慧树平台播放速度和视频进度无关,最高只能1.5倍速)",
  239. unit: "倍",
  240. value: "1",
  241. }, {
  242. title: "跳转间隔",
  243. description: "视频(题目,任务点)完成后n分钟再继续下一个任务,可以有小数点,例如:0.5=30秒",
  244. type: "text",
  245. key: "interval",
  246. unit: "分",
  247. value: "1",
  248. }, {
  249. title: "做题间隔",
  250. description: "每一道题之间填写答案的时间间隔",
  251. type: "text",
  252. key: "topic_interval",
  253. unit: "秒",
  254. value: "5",
  255. }],
  256. }, zhs: {
  257. name: "智慧树",
  258. items: [{
  259. title: "随机答案",
  260. description: "如果题库没有正确的答案会随机选择",
  261. type: "checkbox",
  262. key: "rand_answer",
  263. value: false,
  264. }, {
  265. title: "自动挂机",
  266. description: "进入一个页面就会自动开始挂机,完成一个任务之后会自动进行下一个",
  267. type: "checkbox",
  268. key: "auto",
  269. value: true,
  270. }, {
  271. title: "视频静音",
  272. description: "播放视频时,自动开启静音",
  273. type: "checkbox",
  274. key: "video_mute",
  275. value: true,
  276. }, {
  277. title: "超级模式",
  278. description: "智慧树平台下,超级模式会让任务完成的倍速成真",
  279. type: "checkbox",
  280. key: "super_mode",
  281. value: true,
  282. }, {
  283. title: "播放倍速",
  284. description: "视频播放的倍数,1为正常速度(最高16倍,该功能有一定危险)",
  285. type: "text",
  286. key: "video_multiple",
  287. prompt: "这是一个很危险的功能,建议不要进行调整,如果你想调整播放速度请在下方填写yes(智慧树平台播放速度和视频进度无关,最高只能1.5倍速)",
  288. unit: "倍",
  289. value: "1",
  290. }, {
  291. title: "跳转间隔",
  292. description: "视频完成后n分钟再继续播放下一个,可以有小数点,例如:0.5=30秒",
  293. type: "text",
  294. key: "interval",
  295. unit: "分",
  296. value: "1",
  297. }, {
  298. title: "做题间隔",
  299. description: "每一道题之间填写答案的时间间隔",
  300. type: "text",
  301. key: "topic_interval",
  302. unit: "秒",
  303. value: "5",
  304. }],
  305. }, mooc163: {
  306. name: "中国大学MOOC",
  307. items: [{
  308. title: "随机答案",
  309. description: "如果题库没有正确的答案会随机选择",
  310. type: "checkbox",
  311. key: "rand_answer",
  312. value: false,
  313. }, {
  314. title: "自动挂机",
  315. description: "进入一个页面就会自动开始挂机,完成一个任务之后会自动进行下一个",
  316. type: "checkbox",
  317. key: "auto",
  318. value: true,
  319. }, {
  320. title: "视频静音",
  321. description: "播放视频时,自动开启静音",
  322. type: "checkbox",
  323. key: "video_mute",
  324. value: true,
  325. }, {
  326. title: "忽略题目",
  327. description: "自动挂机时,忽略掉题目不做,直接跳过",
  328. type: "checkbox",
  329. key: "answer_ignore",
  330. value: false,
  331. }, {
  332. title: "播放倍速",
  333. description: "视频播放的倍数,1为正常速度(最高16倍,该功能有一定危险)",
  334. type: "text",
  335. key: "video_multiple",
  336. prompt: "这是一个很危险的功能,建议不要进行调整,如果你想调整播放速度请在下方填写yes(智慧树平台播放速度和视频进度无关,最高只能1.5倍速)",
  337. unit: "倍",
  338. value: "1",
  339. }, {
  340. title: "跳转间隔",
  341. description: "视频完成后n分钟再继续播放下一个,可以有小数点,例如:0.5=30秒",
  342. type: "text",
  343. key: "interval",
  344. unit: "分",
  345. value: "1",
  346. }, {
  347. title: "做题间隔",
  348. description: "每一道题之间填写答案的时间间隔",
  349. type: "text",
  350. key: "topic_interval",
  351. unit: "秒",
  352. value: "5",
  353. }],
  354. },
  355. };
  356. return SystemConfig;
  357. }());
  358. exports.SystemConfig = SystemConfig;
  359. /***/ }),
  360. /***/ "./src/internal/app/question.ts":
  361. /*!**************************************!*\
  362. !*** ./src/internal/app/question.ts ***!
  363. \**************************************/
  364. /*! no static exports found */
  365. /***/ (function(module, exports, __webpack_require__) {
  366. "use strict";
  367. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  368. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  369. return new (P || (P = Promise))(function (resolve, reject) {
  370. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  371. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  372. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  373. step((generator = generator.apply(thisArg, _arguments || [])).next());
  374. });
  375. };
  376. var __generator = (this && this.__generator) || function (thisArg, body) {
  377. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  378. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  379. function verb(n) { return function (v) { return step([n, v]); }; }
  380. function step(op) {
  381. if (f) throw new TypeError("Generator is already executing.");
  382. while (_) try {
  383. 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;
  384. if (y = 0, t) op = [op[0] & 2, t.value];
  385. switch (op[0]) {
  386. case 0: case 1: t = op; break;
  387. case 4: _.label++; return { value: op[1], done: false };
  388. case 5: _.label++; y = op[1]; op = [0]; continue;
  389. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  390. default:
  391. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  392. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  393. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  394. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  395. if (t[2]) _.ops.pop();
  396. _.trys.pop(); continue;
  397. }
  398. op = body.call(thisArg, _);
  399. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  400. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  401. }
  402. };
  403. Object.defineProperty(exports, "__esModule", { value: true });
  404. exports.ToolsQuestionBankFacade = exports.ToolsQuestionBank = exports.SwitchTopicType = exports.QuestionStatusString = exports.TopicStatusString = exports.PushAnswer = void 0;
  405. var utils_1 = __webpack_require__(/*! ../utils/utils */ "./src/internal/utils/utils.ts");
  406. var config_1 = __webpack_require__(/*! @App/config */ "./src/config.ts");
  407. var application_1 = __webpack_require__(/*! ../application */ "./src/internal/application.ts");
  408. var PushAnswer = /** @class */ (function () {
  409. function PushAnswer() {
  410. }
  411. PushAnswer.prototype.Equal = function (content1, content2) {
  412. return content1 == content2;
  413. };
  414. return PushAnswer;
  415. }());
  416. exports.PushAnswer = PushAnswer;
  417. var topicStatusMap = new Map();
  418. topicStatusMap.set("ok", "搜索成功").set("random", "随机答案").set("no_support_random", "不支持的随机答案类型").set("no_answer", "题库中没有搜索到答案").set("no_match", "请手动复制粘贴到棚子AIGC搜索");
  419. var questionStatusMap = new Map();
  420. questionStatusMap.set("success", "搜索成功").set("network", "请手动复制粘贴到棚子AIGC搜索").set("incomplete", "请手动复制粘贴到棚子AIGC搜索").set("processing", "请手动复制粘贴到棚子AIGC搜索");
  421. function TopicStatusString(status) {
  422. return topicStatusMap.get(status) || "未知错误";
  423. }
  424. exports.TopicStatusString = TopicStatusString;
  425. function QuestionStatusString(status) {
  426. return questionStatusMap.get(status) || "未知错误";
  427. }
  428. exports.QuestionStatusString = QuestionStatusString;
  429. function SwitchTopicType(title) {
  430. switch (title) {
  431. case "单选题": {
  432. return 1;
  433. }
  434. case "多选题": {
  435. return 2;
  436. }
  437. case "判断题": {
  438. return 3;
  439. }
  440. case "填空题": {
  441. return 4;
  442. }
  443. default: {
  444. return null;
  445. }
  446. }
  447. }
  448. exports.SwitchTopicType = SwitchTopicType;
  449. // 小工具题库
  450. var ToolsQuestionBank = /** @class */ (function () {
  451. function ToolsQuestionBank(platform, info) {
  452. this.platform = platform;
  453. this.info = info;
  454. }
  455. ToolsQuestionBank.prototype.SetInfo = function (info) {
  456. this.info = info;
  457. };
  458. ToolsQuestionBank.prototype.GetInfo = function () {
  459. return encodeURIComponent(JSON.stringify(this.info));
  460. };
  461. ToolsQuestionBank.prototype.Answer = function (topic, resolve) {
  462. var _this = this;
  463. application_1.Application.App.log.Debug("答案查询", topic);
  464. var num = 20;
  465. var answer = new Array();
  466. var retStatus = "success";
  467. var next = function (index) {
  468. var body = "info=" + _this.GetInfo() + "&";
  469. var t = index;
  470. for (; t < index + num && t < topic.length; t++) {
  471. var val = topic[t];
  472. body += "topic[" + (t - index) + "]=" + encodeURIComponent((val.topic)) + "&type[" + (t - index) + "]=" + val.type + "&";
  473. }
  474. utils_1.HttpUtils.HttpPost(config_1.SystemConfig.url + "v2/answer?platform=" + _this.platform, body, {
  475. headers: {
  476. "Authorization": application_1.Application.App.config.vtoken,
  477. "X-Version": config_1.SystemConfig.version.toString(),
  478. },
  479. json: true,
  480. success: function (result) { return __awaiter(_this, void 0, void 0, function () {
  481. var status, tmpResult, i, val;
  482. return __generator(this, function (_a) {
  483. switch (_a.label) {
  484. case 0:
  485. status = "success";
  486. tmpResult = new Array();
  487. for (i = 0; i < result.length; i++) {
  488. if (result[i].result == undefined || result[i].result.length <= 0) {
  489. tmpResult.push({
  490. index: index + result[i].index,
  491. topic: result[i].topic,
  492. type: -1,
  493. status: "no_answer",
  494. answers: null,
  495. correct: null,
  496. Equal: this.Equal,
  497. });
  498. status = "incomplete";
  499. continue;
  500. }
  501. val = result[i].result[0];
  502. tmpResult.push({
  503. index: index + result[i].index,
  504. topic: val.topic,
  505. type: val.type,
  506. correct: val.correct,
  507. status: "ok",
  508. Equal: this.Equal,
  509. });
  510. }
  511. answer = answer.concat(tmpResult);
  512. if (status != "success") {
  513. retStatus = status;
  514. }
  515. return [4 /*yield*/, resolve({ status: "processing", answer: tmpResult })];
  516. case 1:
  517. _a.sent();
  518. if (t < topic.length) {
  519. next(t);
  520. }
  521. else {
  522. return [2 /*return*/, resolve({ status: retStatus, answer: answer })];
  523. }
  524. return [2 /*return*/];
  525. }
  526. });
  527. }); },
  528. error: function () {
  529. return resolve({ status: "network", answer: answer });
  530. }
  531. });
  532. };
  533. next(0);
  534. };
  535. ToolsQuestionBank.prototype.Push = function (answer) {
  536. var _this = this;
  537. return new Promise(function (resolve) {
  538. application_1.Application.App.log.Debug("采集提交", answer);
  539. utils_1.HttpUtils.HttpPost(config_1.SystemConfig.url + "answer?platform=" + _this.platform, "info=" + _this.GetInfo() + "&data=" + encodeURIComponent(JSON.stringify(answer)), {
  540. headers: {
  541. "Authorization": application_1.Application.App.config.vtoken,
  542. "X-Version": config_1.SystemConfig.version.toString(),
  543. },
  544. json: true,
  545. success: function (result) {
  546. application_1.Application.App.log.Info("答案自动记录成功,成功获得" + result.add_token_num + "个打码数,剩余数量:" + result.token_num);
  547. resolve("success");
  548. },
  549. error: function () {
  550. resolve("network");
  551. }
  552. });
  553. });
  554. };
  555. ToolsQuestionBank.prototype.Equal = function (content1, content2) {
  556. return utils_1.removeHTML(content1) == utils_1.removeHTML(content2);
  557. };
  558. ToolsQuestionBank.prototype.CheckCourse = function (info) {
  559. var _this = this;
  560. return new Promise(function (resolve) {
  561. info = info || [_this.info];
  562. utils_1.HttpUtils.HttpPost(config_1.SystemConfig.url + "v2/check?platform=" + _this.platform, "info=" + encodeURIComponent(JSON.stringify(info)), {
  563. headers: {
  564. "Authorization": application_1.Application.App.config.vtoken,
  565. "X-Version": config_1.SystemConfig.version.toString(),
  566. },
  567. success: function () {
  568. resolve(0);
  569. }, error: function () {
  570. resolve(-1);
  571. }
  572. });
  573. resolve();
  574. });
  575. };
  576. return ToolsQuestionBank;
  577. }());
  578. exports.ToolsQuestionBank = ToolsQuestionBank;
  579. var ToolsQuestionBankFacade = /** @class */ (function () {
  580. function ToolsQuestionBankFacade(platform, info) {
  581. if (typeof platform == "string") {
  582. this.bank = new ToolsQuestionBank(platform, info);
  583. }
  584. else {
  585. this.bank = platform;
  586. }
  587. this.question = new Array();
  588. }
  589. ToolsQuestionBankFacade.prototype.ClearQuestion = function () {
  590. this.question = new Array();
  591. };
  592. ToolsQuestionBankFacade.prototype.AddQuestion = function (q) {
  593. this.question.push(q);
  594. };
  595. ToolsQuestionBankFacade.prototype.Answer = function (callback) {
  596. var _this = this;
  597. var topic = new Array();
  598. this.question.forEach(function (val) {
  599. var type = val.GetType();
  600. if (type == -1) {
  601. return;
  602. }
  603. topic.push({
  604. topic: (val.GetTopic()),
  605. type: type,
  606. });
  607. });
  608. var status = "success";
  609. this.bank.Answer(topic, function (ret) {
  610. return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
  611. var t, i, answer, question, tmpStatus;
  612. return __generator(this, function (_a) {
  613. switch (_a.label) {
  614. case 0:
  615. if (ret.status != "processing") {
  616. application_1.Application.App.log.Debug("题库返回", ret);
  617. if (ret.status != "success" || status == "success") {
  618. callback(ret.status);
  619. return [2 /*return*/, resolve()];
  620. }
  621. callback(status);
  622. return [2 /*return*/, resolve()];
  623. }
  624. t = application_1.Application.App.config.topic_interval * 1000;
  625. i = 0;
  626. _a.label = 1;
  627. case 1:
  628. if (!(i < ret.answer.length)) return [3 /*break*/, 11];
  629. answer = ret.answer[i];
  630. question = this.question[answer.index];
  631. tmpStatus = answer.status;
  632. if (!(answer.status == "no_answer")) return [3 /*break*/, 3];
  633. status = this.randAnswer(status, tmpStatus, question);
  634. return [4 /*yield*/, utils_1.Sleep(t)];
  635. case 2:
  636. _a.sent();
  637. return [3 /*break*/, 10];
  638. case 3:
  639. if (!(answer.type != question.GetType())) return [3 /*break*/, 4];
  640. tmpStatus = "no_match";
  641. return [3 /*break*/, 6];
  642. case 4: return [4 /*yield*/, question.Fill(answer)];
  643. case 5:
  644. tmpStatus = _a.sent();
  645. _a.label = 6;
  646. case 6:
  647. if (!(tmpStatus == "no_match")) return [3 /*break*/, 8];
  648. status = this.randAnswer(status, tmpStatus, question);
  649. return [4 /*yield*/, utils_1.Sleep(t)];
  650. case 7:
  651. _a.sent();
  652. return [3 /*break*/, 10];
  653. case 8:
  654. question.SetStatus(tmpStatus);
  655. if (!(i < ret.answer.length - 1)) return [3 /*break*/, 10];
  656. return [4 /*yield*/, utils_1.Sleep(t)];
  657. case 9:
  658. _a.sent();
  659. _a.label = 10;
  660. case 10:
  661. i++;
  662. return [3 /*break*/, 1];
  663. case 11: return [2 /*return*/, resolve()];
  664. }
  665. });
  666. }); });
  667. });
  668. };
  669. ToolsQuestionBankFacade.prototype.randAnswer = function (status, tmpStatus, question) {
  670. if (application_1.Application.App.config.rand_answer) {
  671. tmpStatus = question.Random();
  672. }
  673. else {
  674. status = "incomplete";
  675. }
  676. if (tmpStatus == "no_support_random") {
  677. status = "incomplete";
  678. }
  679. question.SetStatus(tmpStatus);
  680. return status;
  681. };
  682. ToolsQuestionBankFacade.prototype.Push = function (callback) {
  683. var answer = new Array();
  684. this.question.forEach(function (val) {
  685. var correct = val.Correct();
  686. if (correct == null || correct.correct == null || correct.type == -1) {
  687. return;
  688. }
  689. answer.push(correct);
  690. });
  691. this.bank.Push(answer).then(function (ret) {
  692. application_1.Application.App.log.Debug("题库返回", ret);
  693. return callback(ret);
  694. });
  695. };
  696. ToolsQuestionBankFacade.prototype.dealOption = function (options) {
  697. for (var i = 0; i < options.length; i++) {
  698. if (typeof options[i].content == "string") {
  699. options[i].content = (options[i].content);
  700. }
  701. }
  702. return options;
  703. };
  704. ToolsQuestionBankFacade.prototype.CheckCourse = function () {
  705. return this.bank.CheckCourse();
  706. };
  707. return ToolsQuestionBankFacade;
  708. }());
  709. exports.ToolsQuestionBankFacade = ToolsQuestionBankFacade;
  710. /***/ }),
  711. /***/ "./src/internal/app/task.ts":
  712. /*!**********************************!*\
  713. !*** ./src/internal/app/task.ts ***!
  714. \**********************************/
  715. /*! no static exports found */
  716. /***/ (function(module, exports, __webpack_require__) {
  717. "use strict";
  718. var __extends = (this && this.__extends) || (function () {
  719. var extendStatics = function (d, b) {
  720. extendStatics = Object.setPrototypeOf ||
  721. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  722. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  723. return extendStatics(d, b);
  724. };
  725. return function (d, b) {
  726. extendStatics(d, b);
  727. function __() { this.constructor = d; }
  728. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  729. };
  730. })();
  731. Object.defineProperty(exports, "__esModule", { value: true });
  732. exports.Task = void 0;
  733. var event_1 = __webpack_require__(/*! @App/internal/utils/event */ "./src/internal/utils/event.ts");
  734. var Task = /** @class */ (function (_super) {
  735. __extends(Task, _super);
  736. function Task() {
  737. return _super !== null && _super.apply(this, arguments) || this;
  738. }
  739. // 初始化任务
  740. Task.prototype.Init = function () {
  741. return new Promise(function (resolve) {
  742. return resolve();
  743. });
  744. };
  745. // 提交任务,例如topic的类型,可以在本接口内进行提交操作
  746. Task.prototype.Submit = function () {
  747. return new Promise(function (resolve) {
  748. return resolve();
  749. });
  750. };
  751. // 停止任务
  752. Task.prototype.Stop = function () {
  753. return new Promise(function (resolve) {
  754. return resolve();
  755. });
  756. };
  757. // 任务的上下文(对于某些iframe的可能会用到)
  758. Task.prototype.Context = function () {
  759. return window;
  760. };
  761. return Task;
  762. }(event_1.EventListener));
  763. exports.Task = Task;
  764. /***/ }),
  765. /***/ "./src/internal/app/topic.ts":
  766. /*!***********************************!*\
  767. !*** ./src/internal/app/topic.ts ***!
  768. \***********************************/
  769. /*! no static exports found */
  770. /***/ (function(module, exports, __webpack_require__) {
  771. "use strict";
  772. Object.defineProperty(exports, "__esModule", { value: true });
  773. exports.Topic = void 0;
  774. var application_1 = __webpack_require__(/*! ../application */ "./src/internal/application.ts");
  775. var config_1 = __webpack_require__(/*! @App/config */ "./src/config.ts");
  776. // 题目任务点
  777. var Topic = /** @class */ (function () {
  778. function Topic(content, answer) {
  779. this.answer = answer;
  780. this.context = content;
  781. }
  782. Topic.prototype.SetQueryQuestions = function (queryQuestions) {
  783. this.queryQuestions = queryQuestions;
  784. };
  785. Topic.prototype.addQuestion = function () {
  786. var _this = this;
  787. var questions = this.queryQuestions.QueryQuestions();
  788. this.answer.ClearQuestion();
  789. questions.forEach(function (val) {
  790. _this.answer.AddQuestion(val);
  791. });
  792. };
  793. Topic.prototype.QueryAnswer = function () {
  794. var _this = this;
  795. return new Promise(function (resolve) {
  796. if (_this.lock) {
  797. return resolve("processing");
  798. }
  799. _this.lock = true;
  800. application_1.Application.App.log.Info('<a href="https://nishang.site/" target="_blank">点击打开 棚子AIGC</a>...');
  801. _this.addQuestion();
  802. _this.answer.Answer(function (status) {
  803. _this.lock = false;
  804. resolve(status);
  805. if (status == "network") {
  806. return application_1.Application.App.log.Error("手动答题更高效:" + config_1.SystemConfig.url);
  807. }
  808. else if (status == "incomplete") {
  809. return application_1.Application.App.log.Warn("题库答案不全,请手动填写操作");
  810. }
  811. });
  812. });
  813. };
  814. Topic.prototype.CollectAnswer = function () {
  815. var _this = this;
  816. return new Promise(function (resolve) {
  817. application_1.Application.App.log.Debug("收集题目答案", _this.context);
  818. _this.addQuestion();
  819. _this.answer.Push(function (status) {
  820. application_1.Application.App.log.Debug("采集答案返回", status);
  821. resolve();
  822. });
  823. });
  824. };
  825. return Topic;
  826. }());
  827. exports.Topic = Topic;
  828. /***/ }),
  829. /***/ "./src/internal/app/vcode.ts":
  830. /*!***********************************!*\
  831. !*** ./src/internal/app/vcode.ts ***!
  832. \***********************************/
  833. /*! no static exports found */
  834. /***/ (function(module, exports, __webpack_require__) {
  835. "use strict";
  836. Object.defineProperty(exports, "__esModule", { value: true });
  837. exports.VCode = void 0;
  838. var utils_1 = __webpack_require__(/*! @App/internal/utils/utils */ "./src/internal/utils/utils.ts");
  839. var config_1 = __webpack_require__(/*! @App/config */ "./src/config.ts");
  840. var application_1 = __webpack_require__(/*! ../application */ "./src/internal/application.ts");
  841. var VCode = /** @class */ (function () {
  842. function VCode(listen) {
  843. this.listen = listen;
  844. }
  845. VCode.prototype.Init = function () {
  846. var _this = this;
  847. this.listen.Listen(function (fill) {
  848. application_1.Application.App.log.Info("准备进行打码");
  849. _this.getVcode(fill);
  850. });
  851. };
  852. VCode.prototype.getVcode = function (fill) {
  853. var img = fill.GetImage();
  854. var base64 = "";
  855. if (typeof img == "string") {
  856. base64 = img;
  857. }
  858. else {
  859. base64 = utils_1.getImageBase64(img, 'jpeg');
  860. }
  861. utils_1.HttpUtils.HttpPost(config_1.SystemConfig.url + 'vcode', 'img=' + encodeURIComponent(base64.substr('data:image/jpeg;base64,'.length)), {
  862. headers: {
  863. "Authorization": application_1.Application.App.config.vtoken,
  864. "X-Version": config_1.SystemConfig.version.toString(),
  865. },
  866. json: false,
  867. success: function (ret) {
  868. var json = JSON.parse(ret);
  869. application_1.Application.App.log.Debug(json);
  870. if (json.code == -2) {
  871. fill.Fill("error", json.msg, "");
  872. }
  873. else if (json.code == -1) {
  874. fill.Fill("error", "打码服务器发生错误", "");
  875. }
  876. else if (json.msg) {
  877. fill.Fill("ok", "打码成功", json.msg);
  878. }
  879. else {
  880. fill.Fill("error", "未知错误", "");
  881. }
  882. },
  883. error: function () {
  884. fill.Fill("network", "网络请求失败", "");
  885. }
  886. });
  887. };
  888. return VCode;
  889. }());
  890. exports.VCode = VCode;
  891. /***/ }),
  892. /***/ "./src/internal/application.ts":
  893. /*!*************************************!*\
  894. !*** ./src/internal/application.ts ***!
  895. \*************************************/
  896. /*! no static exports found */
  897. /***/ (function(module, exports, __webpack_require__) {
  898. "use strict";
  899. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  900. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  901. return new (P || (P = Promise))(function (resolve, reject) {
  902. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  903. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  904. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  905. step((generator = generator.apply(thisArg, _arguments || [])).next());
  906. });
  907. };
  908. var __generator = (this && this.__generator) || function (thisArg, body) {
  909. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  910. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  911. function verb(n) { return function (v) { return step([n, v]); }; }
  912. function step(op) {
  913. if (f) throw new TypeError("Generator is already executing.");
  914. while (_) try {
  915. 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;
  916. if (y = 0, t) op = [op[0] & 2, t.value];
  917. switch (op[0]) {
  918. case 0: case 1: t = op; break;
  919. case 4: _.label++; return { value: op[1], done: false };
  920. case 5: _.label++; y = op[1]; op = [0]; continue;
  921. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  922. default:
  923. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  924. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  925. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  926. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  927. if (t[2]) _.ops.pop();
  928. _.trys.pop(); continue;
  929. }
  930. op = body.call(thisArg, _);
  931. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  932. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  933. }
  934. };
  935. Object.defineProperty(exports, "__esModule", { value: true });
  936. exports.Application = exports.AppName = exports.Content = exports.Frontend = exports.Backend = void 0;
  937. var message_1 = __webpack_require__(/*! ./utils/message */ "./src/internal/utils/message.ts");
  938. var utils_1 = __webpack_require__(/*! ./utils/utils */ "./src/internal/utils/utils.ts");
  939. var config_1 = __webpack_require__(/*! @App/config */ "./src/config.ts");
  940. exports.Backend = "backend";
  941. exports.Frontend = "frontend";
  942. exports.Content = "content";
  943. exports.AppName = "cxmooc-tools";
  944. var Application = /** @class */ (function () {
  945. function Application(runEnv, launcher, component) {
  946. Application.app = this;
  947. Application.runEnv = runEnv;
  948. this.runEnvSwitch(runEnv);
  949. this.launcher = launcher;
  950. this.component = component;
  951. }
  952. Object.defineProperty(Application, "App", {
  953. get: function () {
  954. return Application.app;
  955. },
  956. enumerable: false,
  957. configurable: true
  958. });
  959. Object.defineProperty(Application.prototype, "debug", {
  960. get: function () {
  961. return "development" == "development";
  962. },
  963. enumerable: false,
  964. configurable: true
  965. });
  966. Object.defineProperty(Application.prototype, "prod", {
  967. get: function () {
  968. return "development" == "production";
  969. },
  970. enumerable: false,
  971. configurable: true
  972. });
  973. Object.defineProperty(Application.prototype, "config", {
  974. get: function () {
  975. return this.component.get("config");
  976. },
  977. enumerable: false,
  978. configurable: true
  979. });
  980. Object.defineProperty(Application.prototype, "log", {
  981. get: function () {
  982. return this.component.get("logger");
  983. },
  984. enumerable: false,
  985. configurable: true
  986. });
  987. Application.prototype.run = function () {
  988. this.launcher.start();
  989. };
  990. Object.defineProperty(Application.prototype, "IsFrontend", {
  991. get: function () {
  992. return Application.IsFrontend;
  993. },
  994. enumerable: false,
  995. configurable: true
  996. });
  997. Object.defineProperty(Application.prototype, "IsBackend", {
  998. get: function () {
  999. return Application.IsBackend;
  1000. },
  1001. enumerable: false,
  1002. configurable: true
  1003. });
  1004. Object.defineProperty(Application.prototype, "IsContent", {
  1005. get: function () {
  1006. return Application.IsContent;
  1007. },
  1008. enumerable: false,
  1009. configurable: true
  1010. });
  1011. Application.prototype.runEnvSwitch = function (env) {
  1012. switch (env) {
  1013. case exports.Frontend:
  1014. Application.IsFrontend = true;
  1015. break;
  1016. case exports.Backend:
  1017. Application.IsBackend = true;
  1018. break;
  1019. case exports.Content:
  1020. Application.IsContent = true;
  1021. break;
  1022. }
  1023. ;
  1024. };
  1025. Object.defineProperty(Application.prototype, "Client", {
  1026. get: function () {
  1027. if (Application.IsFrontend) {
  1028. return message_1.NewChromeClientMessage(exports.AppName);
  1029. }
  1030. return message_1.NewExtensionClientMessage(exports.AppName);
  1031. },
  1032. enumerable: false,
  1033. configurable: true
  1034. });
  1035. Application.CheckUpdate = function (callback) {
  1036. if (Application.IsContent) {
  1037. chrome.storage.local.get(["version", "enforce", "hotversion", "url"], function (item) {
  1038. return __awaiter(this, void 0, void 0, function () {
  1039. return __generator(this, function (_a) {
  1040. switch (_a.label) {
  1041. case 0: return [4 /*yield*/, callback((config_1.SystemConfig.version < item.version), item)];
  1042. case 1:
  1043. _a.sent();
  1044. return [2 /*return*/];
  1045. }
  1046. });
  1047. });
  1048. });
  1049. return;
  1050. }
  1051. utils_1.HttpUtils.HttpGet(config_1.SystemConfig.url + "update?ver=" + config_1.SystemConfig.version, {
  1052. json: true,
  1053. success: function (json) {
  1054. return __awaiter(this, void 0, void 0, function () {
  1055. var data;
  1056. return __generator(this, function (_a) {
  1057. switch (_a.label) {
  1058. case 0:
  1059. data = {
  1060. version: json.version,
  1061. url: json.url,
  1062. enforce: json.enforce,
  1063. hotversion: json.hotversion,
  1064. injection: json.injection,
  1065. };
  1066. Application.IsContent && chrome.storage.local.set(data);
  1067. return [4 /*yield*/, callback((config_1.SystemConfig.version < data.version), data)];
  1068. case 1:
  1069. _a.sent();
  1070. return [2 /*return*/];
  1071. }
  1072. });
  1073. });
  1074. }, error: function () {
  1075. return __awaiter(this, void 0, void 0, function () {
  1076. return __generator(this, function (_a) {
  1077. switch (_a.label) {
  1078. case 0: return [4 /*yield*/, callback(false, undefined)];
  1079. case 1:
  1080. _a.sent();
  1081. return [2 /*return*/];
  1082. }
  1083. });
  1084. });
  1085. }
  1086. });
  1087. };
  1088. return Application;
  1089. }());
  1090. exports.Application = Application;
  1091. /***/ }),
  1092. /***/ "./src/internal/utils/config.ts":
  1093. /*!**************************************!*\
  1094. !*** ./src/internal/utils/config.ts ***!
  1095. \**************************************/
  1096. /*! no static exports found */
  1097. /***/ (function(module, exports, __webpack_require__) {
  1098. "use strict";
  1099. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  1100. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  1101. return new (P || (P = Promise))(function (resolve, reject) {
  1102. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  1103. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  1104. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  1105. step((generator = generator.apply(thisArg, _arguments || [])).next());
  1106. });
  1107. };
  1108. var __generator = (this && this.__generator) || function (thisArg, body) {
  1109. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  1110. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  1111. function verb(n) { return function (v) { return step([n, v]); }; }
  1112. function step(op) {
  1113. if (f) throw new TypeError("Generator is already executing.");
  1114. while (_) try {
  1115. 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;
  1116. if (y = 0, t) op = [op[0] & 2, t.value];
  1117. switch (op[0]) {
  1118. case 0: case 1: t = op; break;
  1119. case 4: _.label++; return { value: op[1], done: false };
  1120. case 5: _.label++; y = op[1]; op = [0]; continue;
  1121. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  1122. default:
  1123. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  1124. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  1125. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  1126. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  1127. if (t[2]) _.ops.pop();
  1128. _.trys.pop(); continue;
  1129. }
  1130. op = body.call(thisArg, _);
  1131. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  1132. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  1133. }
  1134. };
  1135. Object.defineProperty(exports, "__esModule", { value: true });
  1136. exports.NewFrontendGetConfig = exports.NewBackendConfig = exports.ChromeConfigItems = void 0;
  1137. var utils_1 = __webpack_require__(/*! ./utils */ "./src/internal/utils/utils.ts");
  1138. var application_1 = __webpack_require__(/*! ../application */ "./src/internal/application.ts");
  1139. var config_1 = __webpack_require__(/*! @App/config */ "./src/config.ts");
  1140. // 缓存默认值
  1141. var configDefaultValue = new Map();
  1142. configDefaultValue.set("vtoken", "");
  1143. for (var key in config_1.SystemConfig.config) {
  1144. for (var i = 0; i < config_1.SystemConfig.config[key].items.length; i++) {
  1145. configDefaultValue.set(key + "_" + config_1.SystemConfig.config[key].items[i].key, config_1.SystemConfig.config[key].items[i].value);
  1146. }
  1147. }
  1148. var ChromeConfigItems = /** @class */ (function () {
  1149. function ChromeConfigItems(config) {
  1150. var _this = this;
  1151. this.Namespace = "";
  1152. this.config = config;
  1153. var list = [];
  1154. configDefaultValue.forEach(function (val, key) {
  1155. list.push(key);
  1156. });
  1157. this.config.Watch(list, function (key, val) {
  1158. _this.localCache[key] = val;
  1159. });
  1160. this.localCache = localStorage;
  1161. }
  1162. // 设置配置的命名空间,储存格式为 namepace_configkey
  1163. ChromeConfigItems.prototype.SetNamespace = function (namespace) {
  1164. this.Namespace = namespace + "_";
  1165. };
  1166. ChromeConfigItems.prototype.ConfigList = function () {
  1167. return this.config.ConfigList();
  1168. };
  1169. ChromeConfigItems.prototype.SetNamespaceConfig = function (namespace, key, val) {
  1170. return this.config.SetConfig(namespace + "_" + key, val);
  1171. };
  1172. ChromeConfigItems.prototype.GetNamespaceConfig = function (namespace, key, defaultVal) {
  1173. return this.config.GetConfig(namespace + "_" + key, defaultVal);
  1174. };
  1175. ChromeConfigItems.prototype.GetConfig = function (key, defaultVal) {
  1176. var val = this.config.GetConfig(this.Namespace + key);
  1177. if (val == undefined) {
  1178. return this.config.GetConfig(key, defaultVal);
  1179. }
  1180. return val || defaultVal;
  1181. };
  1182. ChromeConfigItems.prototype.Watch = function (key, callback) {
  1183. this.config.Watch(key, callback);
  1184. };
  1185. Object.defineProperty(ChromeConfigItems.prototype, "super_mode", {
  1186. get: function () {
  1187. return utils_1.toBool(this.GetConfig("super_mode", "true"));
  1188. },
  1189. enumerable: false,
  1190. configurable: true
  1191. });
  1192. Object.defineProperty(ChromeConfigItems.prototype, "vtoken", {
  1193. get: function () {
  1194. return this.GetConfig("vtoken", "");
  1195. },
  1196. enumerable: false,
  1197. configurable: true
  1198. });
  1199. Object.defineProperty(ChromeConfigItems.prototype, "rand_answer", {
  1200. get: function () {
  1201. return utils_1.toBool(this.GetConfig("rand_answer", "false"));
  1202. },
  1203. enumerable: false,
  1204. configurable: true
  1205. });
  1206. Object.defineProperty(ChromeConfigItems.prototype, "auto", {
  1207. get: function () {
  1208. return utils_1.toBool(this.GetConfig("auto", "true"));
  1209. },
  1210. set: function (val) {
  1211. this.SetConfig("auto", utils_1.boolToString(val));
  1212. },
  1213. enumerable: false,
  1214. configurable: true
  1215. });
  1216. Object.defineProperty(ChromeConfigItems.prototype, "video_mute", {
  1217. get: function () {
  1218. return utils_1.toBool(this.GetConfig("video_mute", "true"));
  1219. },
  1220. enumerable: false,
  1221. configurable: true
  1222. });
  1223. Object.defineProperty(ChromeConfigItems.prototype, "answer_ignore", {
  1224. get: function () {
  1225. return utils_1.toBool(this.GetConfig("answer_ignore", "false"));
  1226. },
  1227. enumerable: false,
  1228. configurable: true
  1229. });
  1230. Object.defineProperty(ChromeConfigItems.prototype, "video_cdn", {
  1231. get: function () {
  1232. var val = this.GetConfig("video_cdn");
  1233. if (val == "默认") {
  1234. return "";
  1235. }
  1236. return val;
  1237. },
  1238. enumerable: false,
  1239. configurable: true
  1240. });
  1241. Object.defineProperty(ChromeConfigItems.prototype, "video_multiple", {
  1242. get: function () {
  1243. return parseFloat(this.GetConfig("video_multiple"));
  1244. },
  1245. enumerable: false,
  1246. configurable: true
  1247. });
  1248. Object.defineProperty(ChromeConfigItems.prototype, "interval", {
  1249. get: function () {
  1250. var interval = parseFloat(this.GetConfig("interval", "0.1"));
  1251. interval = interval * 100;
  1252. return Math.floor(utils_1.randNumber(interval - interval / 2, interval + interval / 2)) / 100;
  1253. },
  1254. enumerable: false,
  1255. configurable: true
  1256. });
  1257. ChromeConfigItems.prototype.SetConfig = function (key, val) {
  1258. return this.config.SetConfig(this.Namespace + key, val);
  1259. };
  1260. Object.defineProperty(ChromeConfigItems.prototype, "topic_interval", {
  1261. get: function () {
  1262. return parseInt(this.GetConfig("topic_interval", "5"));
  1263. },
  1264. set: function (val) {
  1265. this.SetConfig("topic_interval", val);
  1266. },
  1267. enumerable: false,
  1268. configurable: true
  1269. });
  1270. return ChromeConfigItems;
  1271. }());
  1272. exports.ChromeConfigItems = ChromeConfigItems;
  1273. // 后台环境中使用
  1274. function NewBackendConfig() {
  1275. var _this = this;
  1276. return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
  1277. var ret;
  1278. return __generator(this, function (_a) {
  1279. switch (_a.label) {
  1280. case 0:
  1281. ret = new backendConfig();
  1282. return [4 /*yield*/, ret.updateCache()];
  1283. case 1:
  1284. _a.sent();
  1285. resolve(ret);
  1286. return [2 /*return*/];
  1287. }
  1288. });
  1289. }); });
  1290. }
  1291. exports.NewBackendConfig = NewBackendConfig;
  1292. var configWatch = /** @class */ (function () {
  1293. function configWatch() {
  1294. this.watchCallback = new Map();
  1295. }
  1296. configWatch.prototype.WatchEvent = function (key, val) {
  1297. var list = this.watchCallback.get(key);
  1298. if (list != undefined) {
  1299. list.forEach(function (v) {
  1300. v(key, val);
  1301. });
  1302. }
  1303. list = this.watchCallback.get("*");
  1304. if (list != undefined) {
  1305. list.forEach(function (v) {
  1306. v(key, val);
  1307. });
  1308. }
  1309. };
  1310. configWatch.prototype.Watch = function (key, callback) {
  1311. var _this = this;
  1312. if (typeof key == "string") {
  1313. this.setWatchMap(key, callback);
  1314. return;
  1315. }
  1316. key.forEach(function (val, index) {
  1317. _this.setWatchMap(val, callback);
  1318. });
  1319. };
  1320. configWatch.prototype.setWatchMap = function (key, callback) {
  1321. var list = this.watchCallback.get(key);
  1322. if (list == undefined) {
  1323. list = new Array();
  1324. }
  1325. list.push(callback);
  1326. this.watchCallback.set(key, list);
  1327. };
  1328. return configWatch;
  1329. }());
  1330. var backendConfig = /** @class */ (function () {
  1331. function backendConfig() {
  1332. var _this = this;
  1333. this.watch = new configWatch();
  1334. chrome.runtime.onMessage.addListener(function (request) {
  1335. if (request.type && request.type == "cxconfig") {
  1336. _this.cache[request.key] = request.value;
  1337. _this.watch.WatchEvent(request.key, request.value);
  1338. _this.updateConfigStorage();
  1339. }
  1340. });
  1341. }
  1342. // 更新配置转为json,存入
  1343. backendConfig.prototype.updateConfigStorage = function () {
  1344. var txt = JSON.stringify(this.cache);
  1345. chrome.storage.sync.set({ "config_storage": txt });
  1346. };
  1347. // 更新缓存
  1348. backendConfig.prototype.updateCache = function () {
  1349. var _this = this;
  1350. return new Promise(function (resolve) {
  1351. chrome.storage.sync.get("config_storage", function (items) {
  1352. if (items["config_storage"]) {
  1353. _this.cache = JSON.parse(items["config_storage"]);
  1354. }
  1355. else {
  1356. _this.cache = {};
  1357. }
  1358. configDefaultValue.forEach(function (val, key) {
  1359. if (_this.cache[key] === undefined) {
  1360. _this.cache[key] = val;
  1361. }
  1362. });
  1363. _this.updateConfigStorage();
  1364. resolve(undefined);
  1365. });
  1366. });
  1367. };
  1368. backendConfig.prototype.GetConfig = function (key, defaultVal) {
  1369. if (this.cache == undefined) {
  1370. application_1.Application.App.log.Fatal("缓存失败!!!");
  1371. return "";
  1372. }
  1373. return this.cache[key] || defaultVal;
  1374. };
  1375. backendConfig.prototype.Watch = function (key, callback) {
  1376. return this.watch.Watch(key, callback);
  1377. };
  1378. backendConfig.prototype.SetConfig = function (key, val) {
  1379. var _this = this;
  1380. return new Promise(function (resolve) {
  1381. var info = {};
  1382. info[key] = val;
  1383. //通知前端和后端
  1384. _this.cache[key] = val;
  1385. chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
  1386. chrome.tabs.sendMessage(tabs[0].id, { type: "cxconfig", key: key, value: val });
  1387. });
  1388. chrome.runtime.sendMessage({ type: "cxconfig", key: key, value: val });
  1389. _this.updateConfigStorage();
  1390. resolve(undefined);
  1391. });
  1392. };
  1393. backendConfig.prototype.ConfigList = function () {
  1394. var _this = this;
  1395. return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
  1396. return __generator(this, function (_a) {
  1397. switch (_a.label) {
  1398. case 0:
  1399. if (this.cache) {
  1400. return [2 /*return*/, resolve(this.cache)];
  1401. }
  1402. return [4 /*yield*/, this.updateCache()];
  1403. case 1:
  1404. _a.sent();
  1405. resolve(this.cache);
  1406. return [2 /*return*/];
  1407. }
  1408. });
  1409. }); });
  1410. };
  1411. return backendConfig;
  1412. }());
  1413. // 前端环境使用
  1414. function NewFrontendGetConfig() {
  1415. return new frontendGetConfig();
  1416. }
  1417. exports.NewFrontendGetConfig = NewFrontendGetConfig;
  1418. var frontendGetConfig = /** @class */ (function () {
  1419. function frontendGetConfig() {
  1420. var _this = this;
  1421. this.watch = new configWatch();
  1422. this.cache = window.configData || localStorage;
  1423. window.addEventListener('message', function (event) {
  1424. if (event.data.type && event.data.type == "cxconfig") {
  1425. application_1.Application.App.log.Info("配置更新:" + event.data.key + "=" + event.data.value);
  1426. _this.cache[event.data.key] = event.data.value;
  1427. _this.watch.WatchEvent(event.data.key, event.data.value);
  1428. }
  1429. });
  1430. }
  1431. frontendGetConfig.prototype.GetConfig = function (key, defaultVal) {
  1432. if (window.GM_getValue) {
  1433. return window.GM_getValue(key, defaultVal);
  1434. }
  1435. return this.cache[key] || defaultVal;
  1436. };
  1437. frontendGetConfig.prototype.Watch = function (key, callback) {
  1438. return this.watch.Watch(key, callback);
  1439. };
  1440. frontendGetConfig.prototype.SetConfig = function (key, val) {
  1441. return __awaiter(this, void 0, void 0, function () {
  1442. return __generator(this, function (_a) {
  1443. this.cache[key] = val;
  1444. if (window.GM_setValue) {
  1445. return [2 /*return*/, window.GM_setValue(key, val)];
  1446. }
  1447. return [2 /*return*/, application_1.Application.App.Client.Send({
  1448. type: "GM_setValue", details: { key: key, val: val },
  1449. })];
  1450. });
  1451. });
  1452. };
  1453. frontendGetConfig.prototype.ConfigList = function () {
  1454. return this.cache;
  1455. };
  1456. return frontendGetConfig;
  1457. }());
  1458. /***/ }),
  1459. /***/ "./src/internal/utils/event.ts":
  1460. /*!*************************************!*\
  1461. !*** ./src/internal/utils/event.ts ***!
  1462. \*************************************/
  1463. /*! no static exports found */
  1464. /***/ (function(module, exports, __webpack_require__) {
  1465. "use strict";
  1466. Object.defineProperty(exports, "__esModule", { value: true });
  1467. exports.EventListener = void 0;
  1468. var EventListener = /** @class */ (function () {
  1469. function EventListener() {
  1470. this.event = {};
  1471. }
  1472. EventListener.prototype.addEventListener = function (event, callback) {
  1473. if (!this.event[event]) {
  1474. this.event[event] = new Array();
  1475. }
  1476. this.event[event].push({
  1477. callback: callback, param: { once: false },
  1478. });
  1479. };
  1480. EventListener.prototype.addEventListenerOnce = function (event, callback) {
  1481. if (!this.event[event]) {
  1482. this.event[event] = new Array();
  1483. }
  1484. this.event[event].push({
  1485. callback: callback, param: { once: true },
  1486. });
  1487. };
  1488. EventListener.prototype.callEvent = function (event) {
  1489. var _this = this;
  1490. var args = [];
  1491. for (var _i = 1; _i < arguments.length; _i++) {
  1492. args[_i - 1] = arguments[_i];
  1493. }
  1494. if (!this.event[event]) {
  1495. return;
  1496. }
  1497. var del = new Array();
  1498. this.event[event].forEach(function (v, index) {
  1499. v.callback.apply(_this, args);
  1500. if (v.param.once) {
  1501. del.push(index);
  1502. }
  1503. });
  1504. del.forEach(function (v, index) {
  1505. _this.event[event].splice(v - index, 1);
  1506. });
  1507. };
  1508. return EventListener;
  1509. }());
  1510. exports.EventListener = EventListener;
  1511. /***/ }),
  1512. /***/ "./src/internal/utils/hook.ts":
  1513. /*!************************************!*\
  1514. !*** ./src/internal/utils/hook.ts ***!
  1515. \************************************/
  1516. /*! no static exports found */
  1517. /***/ (function(module, exports, __webpack_require__) {
  1518. "use strict";
  1519. Object.defineProperty(exports, "__esModule", { value: true });
  1520. exports.Hook = void 0;
  1521. var application_1 = __webpack_require__(/*! @App/internal/application */ "./src/internal/application.ts");
  1522. var Hook = /** @class */ (function () {
  1523. function Hook(func, context) {
  1524. this.context = context || window;
  1525. this.func = func;
  1526. }
  1527. Hook.prototype.Middleware = function (call) {
  1528. var name;
  1529. if (typeof this.func == "string") {
  1530. name = this.func;
  1531. }
  1532. else {
  1533. name = this.func.name;
  1534. }
  1535. var old = this.context[name];
  1536. this.context[name] = function () {
  1537. var args = [old];
  1538. for (var _i = 0; _i < arguments.length; _i++) {
  1539. args[_i + 1] = arguments[_i];
  1540. }
  1541. return call.apply(this, args);
  1542. };
  1543. };
  1544. Hook.HookAjaxRespond = function (url, call) {
  1545. var _this = this;
  1546. if (!this.once) {
  1547. this.match_list = new Map();
  1548. var self_1 = this;
  1549. var hookXMLHttpRequest = new Hook("open", application_1.Application.GlobalContext.XMLHttpRequest.prototype);
  1550. hookXMLHttpRequest.Middleware(function (next) {
  1551. var _this = this;
  1552. var args = [];
  1553. for (var _a = 1; _a < arguments.length; _a++) {
  1554. args[_a - 1] = arguments[_a];
  1555. }
  1556. self_1.match_list.forEach(function (val, key) {
  1557. if (args[1].indexOf(key) != -1) {
  1558. Object.defineProperty(_this, "responseText", {
  1559. configurable: true,
  1560. get: function () {
  1561. return val.call(this, args[1], this.response);
  1562. }
  1563. });
  1564. }
  1565. });
  1566. return next.apply(this, args);
  1567. });
  1568. this.once = true;
  1569. }
  1570. if (typeof url == "string") {
  1571. this.match_list.set(url, call);
  1572. }
  1573. else {
  1574. url.forEach(function (v) {
  1575. _this.match_list.set(v, call);
  1576. });
  1577. }
  1578. };
  1579. return Hook;
  1580. }());
  1581. exports.Hook = Hook;
  1582. /***/ }),
  1583. /***/ "./src/internal/utils/log.ts":
  1584. /*!***********************************!*\
  1585. !*** ./src/internal/utils/log.ts ***!
  1586. \***********************************/
  1587. /*! no static exports found */
  1588. /***/ (function(module, exports, __webpack_require__) {
  1589. "use strict";
  1590. var __spreadArrays = (this && this.__spreadArrays) || function () {
  1591. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  1592. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  1593. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  1594. r[k] = a[j];
  1595. return r;
  1596. };
  1597. Object.defineProperty(exports, "__esModule", { value: true });
  1598. exports.PageLog = exports.ConsoleLog = void 0;
  1599. var application_1 = __webpack_require__(/*! ../application */ "./src/internal/application.ts");
  1600. __webpack_require__(/*! ../../views/common */ "./src/views/common.ts");
  1601. var utils_1 = __webpack_require__(/*! @App/internal/utils/utils */ "./src/internal/utils/utils.ts");
  1602. // 开发者工具f12处打印日志
  1603. var ConsoleLog = /** @class */ (function () {
  1604. function ConsoleLog() {
  1605. }
  1606. ConsoleLog.prototype.getNowTime = function () {
  1607. var time = new Date();
  1608. return time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds();
  1609. };
  1610. ConsoleLog.prototype.Debug = function () {
  1611. var args = [];
  1612. for (var _i = 0; _i < arguments.length; _i++) {
  1613. args[_i] = arguments[_i];
  1614. }
  1615. application_1.Application.App.debug && console.info.apply(console, __spreadArrays(["[debug " + this.getNowTime() + "]"], args));
  1616. return this;
  1617. };
  1618. ConsoleLog.prototype.Info = function () {
  1619. var args = [];
  1620. for (var _i = 0; _i < arguments.length; _i++) {
  1621. args[_i] = arguments[_i];
  1622. }
  1623. application_1.Application.App.debug && console.info.apply(console, __spreadArrays(["[info " + this.getNowTime() + "]"], args));
  1624. return this;
  1625. };
  1626. ConsoleLog.prototype.Warn = function () {
  1627. var args = [];
  1628. for (var _i = 0; _i < arguments.length; _i++) {
  1629. args[_i] = arguments[_i];
  1630. }
  1631. console.warn.apply(console, __spreadArrays(["[warn " + this.getNowTime() + "]"], args));
  1632. return this;
  1633. };
  1634. ConsoleLog.prototype.Error = function () {
  1635. var args = [];
  1636. for (var _i = 0; _i < arguments.length; _i++) {
  1637. args[_i] = arguments[_i];
  1638. }
  1639. console.error.apply(console, __spreadArrays(["[error " + this.getNowTime() + "]"], args));
  1640. return this;
  1641. };
  1642. ConsoleLog.prototype.Fatal = function () {
  1643. var args = [];
  1644. for (var _i = 0; _i < arguments.length; _i++) {
  1645. args[_i] = arguments[_i];
  1646. }
  1647. console.error.apply(console, __spreadArrays(["[fatal " + this.getNowTime() + "]"], args));
  1648. return this;
  1649. };
  1650. return ConsoleLog;
  1651. }());
  1652. exports.ConsoleLog = ConsoleLog;
  1653. var PageLog = /** @class */ (function () {
  1654. function PageLog() {
  1655. var _this = this;
  1656. this.el = undefined;
  1657. window.addEventListener("load", function () {
  1658. _this.div = document.createElement("div");
  1659. _this.div.innerHTML = "\n <div class=\"head\" id=\"tools-head\"> \n <span>\u7F51\u8BFE\u52A9\u624B</span> \n <span style=\"position:absolute; left:130px;\">\uD83D\uDE46\u200D\u2642\uFE0F \u70B9\u51FB \uD83D\uDC49</span>\n <label class=\"switch\" >\n <input class=\"checkbox-input\" id=\"checkbox\" type=\"checkbox\" checked=\"checked\">\n <label class=\"checkbox\" for=\"checkbox\"></label>\n \n </label>\n <span class=\"close\" style=\"float:right; cursor:pointer; margin-right:5px;\">\u2716</span>\n </div>\n \n <div style=\"background-color: #fff !important; padding-bottom: 60px !important; position: relative !important; min-height: 10px !important;\">\n\n <iframe class=\"iframe\" src=\"https://a.pengzi.cc/index/chaxun\" style=\"width: 100%; height:330px;\"></iframe>\n <div class=\"tools-notice-content\"></div>\n </div>\n ";
  1660. // 添加自定义弹窗
  1661. _this.alertDiv = document.createElement("div");
  1662. _this.alertDiv.className = "custom-alert hidden"; // 为自定义弹窗添加类
  1663. document.body.appendChild(_this.alertDiv);
  1664. _this.div.className = "tools-logger-panel";
  1665. document.body.appendChild(_this.div);
  1666. _this.el = _this.div.querySelector(".tools-notice-content");
  1667. _this.div.querySelector(".close").onclick = function () {
  1668. _this.el = undefined;
  1669. _this.div.remove();
  1670. };
  1671. var checkbox = _this.div.querySelector("#checkbox");
  1672. checkbox.checked = (application_1.Application.App.config.GetConfig("is_notify") || "true") == "true";
  1673. _this.is_notify = checkbox.checked;
  1674. if (!checkbox.checked) {
  1675. checkbox.removeAttribute("checked");
  1676. }
  1677. var self = _this;
  1678. checkbox.addEventListener("change", function () {
  1679. self.is_notify = this.checked;
  1680. application_1.Application.App.config.SetConfig("is_notify", this.checked.toString());
  1681. var iframe = self.div.querySelector(".iframe");
  1682. iframe.style.display = this.checked ? "block" : "none";
  1683. self.showAlert("邀请码6666"); // 显示自定义弹窗
  1684. });
  1685. // 默认.iframe是隐藏的
  1686. var iframe = _this.div.querySelector(".iframe");
  1687. iframe.style.display = "none";
  1688. setTimeout(function () {
  1689. application_1.Application.CheckUpdate(function (isnew, data) {
  1690. if (data == undefined) {
  1691. _this.Info("目前为最新版本.");
  1692. return;
  1693. }
  1694. var html = "";
  1695. if (isnew) {
  1696. html += "<span>[有新版本]</span>";
  1697. }
  1698. html += data.injection;
  1699. _this.Info(html);
  1700. });
  1701. }, 1000);
  1702. // 支持拖拽移动
  1703. function getProperty(ele, prop) {
  1704. return parseInt(window.getComputedStyle(ele)[prop]);
  1705. }
  1706. var windowWidth = window.innerWidth;
  1707. var windowHeight = window.innerHeight;
  1708. var containerWidth = getProperty(_this.div, "width");
  1709. var containerHeight = getProperty(_this.div, "height");
  1710. var x = parseInt(application_1.Application.App.config.GetConfig("notify_tools_x", "60px").replace('px', ''));
  1711. if (x < 0) {
  1712. x = 0;
  1713. }
  1714. if (x >= windowWidth - containerWidth)
  1715. x = windowWidth - containerWidth;
  1716. _this.div.style.left = x + "px";
  1717. var y = parseInt(application_1.Application.App.config.GetConfig("notify_tools_y", "40px").replace('px', ''));
  1718. if (y < 0) {
  1719. y = 0;
  1720. }
  1721. if (y >= windowHeight - containerHeight)
  1722. y = windowHeight - containerHeight;
  1723. _this.div.style.top = y + "px";
  1724. var head = _this.div.querySelector("#tools-head");
  1725. head.onmousedown = function (downEvent) {
  1726. var relaX = downEvent.clientX - _this.div.offsetLeft;
  1727. var relaY = downEvent.clientY - _this.div.offsetTop;
  1728. document.onmousemove = function (moveEvent) {
  1729. var targetX = moveEvent.clientX - relaX;
  1730. var targetY = moveEvent.clientY - relaY;
  1731. if (targetX <= 0)
  1732. targetX = 0;
  1733. if (targetY <= 0)
  1734. targetY = 0;
  1735. if (targetX >= windowWidth - containerWidth)
  1736. targetX = windowWidth - containerWidth;
  1737. if (targetY >= windowHeight - containerHeight)
  1738. targetY = windowHeight - containerHeight;
  1739. _this.div.style.left = targetX + "px";
  1740. _this.div.style.top = targetY + "px";
  1741. };
  1742. document.onmouseup = function () {
  1743. document.onmouseup = null;
  1744. document.onmousemove = null;
  1745. application_1.Application.App.config.SetConfig("notify_tools_x", _this.div.style.left);
  1746. application_1.Application.App.config.SetConfig("notify_tools_y", _this.div.style.top);
  1747. };
  1748. };
  1749. // 添加样式
  1750. var style = document.createElement('style');
  1751. style.innerHTML = "\n .hidden { display: none; }\n .custom-alert {\n position: fixed;\n top: 20px;\n left: 50%;\n transform: translateX(-50%);\n padding: 15px 25px; /* \u589E\u52A0\u5DE6\u53F3\u5185\u8FB9\u8DDD */\n background: linear-gradient(to right, #fb3fbf82, #007affa6); /* \u84DD\u8272\u6E10\u53D8\u80CC\u666F */\n color: white;\n border-radius: 12px; /* \u67D4\u548C\u7684\u5706\u89D2 */\n z-index: 1000;\n box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3); /* \u66F4\u6DF1\u7684\u9634\u5F71\u6548\u679C */\n font-size: 18px; /* \u589E\u52A0\u5B57\u4F53\u5927\u5C0F */\n font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; /* \u4F7F\u7528\u73B0\u4EE3\u5B57\u4F53 */\n transition: opacity 0.5s ease, transform 0.5s ease; /* \u8FC7\u6E21\u6548\u679C */\n opacity: 1; /* \u521D\u59CB\u900F\u660E\u5EA6 */\n transform: translateX(-50%) translateY(0); /* \u521D\u59CB\u4F4D\u7F6E */\n }\n \n .custom-alert.hidden { \n opacity: 0; \n transform: translateX(-50%) translateY(-20px); /* \u79BB\u5F00\u7684\u52A8\u753B */\n }\n\n /* \u989D\u5916\u7684\u52A8\u753B */\n @keyframes slideIn {\n 0% { transform: translateX(-50%) translateY(-20px); opacity: 0; }\n 100% { transform: translateX(-50%) translateY(0); opacity: 1; }\n }\n\n @keyframes slideOut {\n 0% { transform: translateX(-50%) translateY(0); opacity: 1; }\n 100% { transform: translateX(-50%) translateY(-20px); opacity: 0; }\n }\n";
  1752. document.head.appendChild(style);
  1753. });
  1754. }
  1755. PageLog.prototype.getNowTime = function () {
  1756. var time = new Date();
  1757. return time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds();
  1758. };
  1759. PageLog.prototype.first = function (text, color, background) {
  1760. var new_log = document.createElement("div");
  1761. new_log.innerHTML = "\n <div class=\"log\" style=\"border-color: " + background + "; background-color: " + background + ";\">\n <p><span style=\"color:" + color + ";\">" + text + "</span></p>\n </div>\n ";
  1762. var first = document.getElementsByClassName("tools-notice-content")[0].getElementsByTagName("div");
  1763. document.querySelector(".tools-notice-content").insertBefore(new_log, first[0]);
  1764. };
  1765. PageLog.prototype.toStr = function () {
  1766. var args = [];
  1767. for (var _i = 0; _i < arguments.length; _i++) {
  1768. args[_i] = arguments[_i];
  1769. }
  1770. var text = "";
  1771. for (var i = 0; i < args.length; i++) {
  1772. if (typeof args[i] == "object") {
  1773. text += args[i].toString() + "\n";
  1774. }
  1775. else {
  1776. text += args[i] + "\n";
  1777. }
  1778. }
  1779. return text.substring(0, text.length - 1);
  1780. };
  1781. PageLog.prototype.showAlert = function (message) {
  1782. var _this = this;
  1783. this.alertDiv.innerText = message;
  1784. this.alertDiv.classList.remove("hidden");
  1785. this.alertDiv.style.opacity = "1";
  1786. this.alertDiv.style.animation = "slideIn 0.5s forwards"; // 应用弹入动画
  1787. setTimeout(function () {
  1788. _this.alertDiv.style.opacity = "0"; // 渐隐
  1789. _this.alertDiv.style.animation = "slideOut 0.5s forwards"; // 应用弹出动画
  1790. setTimeout(function () {
  1791. _this.alertDiv.classList.add("hidden"); // 完全隐藏
  1792. }, 500); // 等待动画结束后隐藏
  1793. }, 3000);
  1794. };
  1795. PageLog.prototype.Debug = function () {
  1796. var args = [];
  1797. for (var _i = 0; _i < arguments.length; _i++) {
  1798. args[_i] = arguments[_i];
  1799. }
  1800. console.info.apply(console, __spreadArrays(["[debug " + this.getNowTime() + "]"], args));
  1801. return this;
  1802. };
  1803. PageLog.prototype.Info = function () {
  1804. var args = [];
  1805. for (var _i = 0; _i < arguments.length; _i++) {
  1806. args[_i] = arguments[_i];
  1807. }
  1808. var text = this.toStr.apply(this, args);
  1809. if (this.el) {
  1810. this.first(text, "#409EFF", "rgba(121, 187, 255, 0.2)");
  1811. }
  1812. else {
  1813. console.info.apply(console, __spreadArrays(["[info " + this.getNowTime() + "]"], args));
  1814. }
  1815. return this;
  1816. };
  1817. PageLog.prototype.Warn = function () {
  1818. var args = [];
  1819. for (var _i = 0; _i < arguments.length; _i++) {
  1820. args[_i] = arguments[_i];
  1821. }
  1822. var text = this.toStr.apply(this, args);
  1823. if (this.el) {
  1824. this.first(text, "#5C3C00", "rgba(250, 236, 216, 0.4)");
  1825. }
  1826. console.warn.apply(console, __spreadArrays(["[warn " + this.getNowTime() + "]"], args));
  1827. if (document.hidden && localStorage["is_notify"] == "true") {
  1828. utils_1.Noifications({
  1829. title: "网课小工具",
  1830. text: text + "\n3秒后自动关闭",
  1831. timeout: 3000,
  1832. });
  1833. }
  1834. return this;
  1835. };
  1836. PageLog.prototype.Error = function () {
  1837. var args = [];
  1838. for (var _i = 0; _i < arguments.length; _i++) {
  1839. args[_i] = arguments[_i];
  1840. }
  1841. var text = this.toStr.apply(this, args);
  1842. if (this.el) {
  1843. this.first(text, "#FFF0F0", "rgba(253, 226, 226, 0.5)");
  1844. }
  1845. console.error.apply(console, __spreadArrays(["[error " + this.getNowTime() + "]"], args));
  1846. if (localStorage["is_notify"] == "true") {
  1847. utils_1.Noifications({
  1848. title: "网课小工具",
  1849. text: text,
  1850. });
  1851. }
  1852. return this;
  1853. };
  1854. PageLog.prototype.Fatal = function () {
  1855. var args = [];
  1856. for (var _i = 0; _i < arguments.length; _i++) {
  1857. args[_i] = arguments[_i];
  1858. }
  1859. var text = this.toStr.apply(this, args);
  1860. if (this.el) {
  1861. this.first(text, "#ff0000", "rgba(253, 226, 226, 0.5)");
  1862. }
  1863. console.error.apply(console, __spreadArrays(["[fatal " + this.getNowTime() + "]"], args));
  1864. utils_1.Noifications({
  1865. title: "网课小工具",
  1866. text: text,
  1867. });
  1868. return this;
  1869. };
  1870. return PageLog;
  1871. }());
  1872. exports.PageLog = PageLog;
  1873. // export class EmptyLog implements Logger {
  1874. // public Debug(...args: any): Logger {
  1875. // return this;
  1876. // }
  1877. // public Info(...args: any): Logger {
  1878. // return this;
  1879. // }
  1880. // public Warn(...args: any): Logger {
  1881. // return this;
  1882. // }
  1883. // public Error(...args: any): Logger {
  1884. // return this;
  1885. // }
  1886. // public Fatal(...args: any): Logger {
  1887. // return this;
  1888. // }
  1889. // }
  1890. /***/ }),
  1891. /***/ "./src/internal/utils/message.ts":
  1892. /*!***************************************!*\
  1893. !*** ./src/internal/utils/message.ts ***!
  1894. \***************************************/
  1895. /*! no static exports found */
  1896. /***/ (function(module, exports, __webpack_require__) {
  1897. "use strict";
  1898. var __extends = (this && this.__extends) || (function () {
  1899. var extendStatics = function (d, b) {
  1900. extendStatics = Object.setPrototypeOf ||
  1901. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1902. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1903. return extendStatics(d, b);
  1904. };
  1905. return function (d, b) {
  1906. extendStatics(d, b);
  1907. function __() { this.constructor = d; }
  1908. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1909. };
  1910. })();
  1911. Object.defineProperty(exports, "__esModule", { value: true });
  1912. exports.NewChromeClientMessage = exports.NewChromeServerMessage = exports.NewExtensionClientMessage = exports.NewExtensionServerMessage = void 0;
  1913. function NewExtensionServerMessage(port) {
  1914. return new extensionServerMessage(port);
  1915. }
  1916. exports.NewExtensionServerMessage = NewExtensionServerMessage;
  1917. var extensionServerMessage = /** @class */ (function () {
  1918. function extensionServerMessage(port) {
  1919. this.port = port;
  1920. this.recv();
  1921. }
  1922. extensionServerMessage.prototype.recv = function () {
  1923. var _this = this;
  1924. //监听消息
  1925. chrome.runtime.onConnect.addListener(function (port) {
  1926. if (port.name != _this.port) {
  1927. return;
  1928. }
  1929. port.onMessage.addListener(function (request) {
  1930. _this.acceptCallback(new extensionClientMessage(port), request);
  1931. });
  1932. });
  1933. };
  1934. extensionServerMessage.prototype.Accept = function (callback) {
  1935. this.acceptCallback = callback;
  1936. };
  1937. return extensionServerMessage;
  1938. }());
  1939. var msg = /** @class */ (function () {
  1940. function msg(tag) {
  1941. this.tag = tag;
  1942. }
  1943. msg.prototype.Recv = function (callback) {
  1944. this.recvCallback = callback;
  1945. };
  1946. return msg;
  1947. }());
  1948. // 扩展中使用
  1949. function NewExtensionClientMessage(tag) {
  1950. return new extensionClientMessage(tag);
  1951. }
  1952. exports.NewExtensionClientMessage = NewExtensionClientMessage;
  1953. var extensionClientMessage = /** @class */ (function (_super) {
  1954. __extends(extensionClientMessage, _super);
  1955. function extensionClientMessage(param) {
  1956. var _this = this;
  1957. if (typeof param === 'string') {
  1958. _this = _super.call(this, param) || this;
  1959. _this.connect();
  1960. }
  1961. else {
  1962. _this.conn = param;
  1963. }
  1964. _this.recv();
  1965. return _this;
  1966. }
  1967. extensionClientMessage.prototype.connect = function () {
  1968. this.conn = chrome.runtime.connect({ name: this.tag });
  1969. };
  1970. extensionClientMessage.prototype.recv = function () {
  1971. var _this = this;
  1972. this.conn.onMessage.addListener(function (response) {
  1973. _this.recvCallback(response);
  1974. });
  1975. };
  1976. extensionClientMessage.prototype.Send = function (msg) {
  1977. this.conn.postMessage(msg);
  1978. };
  1979. return extensionClientMessage;
  1980. }(msg));
  1981. // 浏览器中使用
  1982. function NewChromeServerMessage(tag) {
  1983. return new chromeServerMessage(tag);
  1984. }
  1985. exports.NewChromeServerMessage = NewChromeServerMessage;
  1986. var chromeServerMessage = /** @class */ (function () {
  1987. function chromeServerMessage(tag) {
  1988. this.tag = tag;
  1989. this.recv();
  1990. }
  1991. chromeServerMessage.prototype.recv = function () {
  1992. var _this = this;
  1993. window.addEventListener('message', function (event) {
  1994. if (event.data.tag == _this.tag && event.data.conn_tag && event.data.source == "client") {
  1995. _this.acceptCallback(new chromeClientMessage(_this.tag, event.data.conn_tag), event.data.msg);
  1996. }
  1997. });
  1998. };
  1999. chromeServerMessage.prototype.Accept = function (callback) {
  2000. this.acceptCallback = callback;
  2001. };
  2002. return chromeServerMessage;
  2003. }());
  2004. function NewChromeClientMessage(tag) {
  2005. return new chromeClientMessage(tag);
  2006. }
  2007. exports.NewChromeClientMessage = NewChromeClientMessage;
  2008. var chromeClientMessage = /** @class */ (function (_super) {
  2009. __extends(chromeClientMessage, _super);
  2010. function chromeClientMessage(tag, conn) {
  2011. var _this = this;
  2012. if (conn !== undefined) {
  2013. _this = _super.call(this, tag) || this;
  2014. _this.connTag = conn;
  2015. _this.source = "server";
  2016. }
  2017. else {
  2018. _this = _super.call(this, tag) || this;
  2019. _this.connect();
  2020. _this.source = "client";
  2021. }
  2022. return _this;
  2023. }
  2024. chromeClientMessage.prototype.connect = function () {
  2025. var _this = this;
  2026. this.connTag = Math.random();
  2027. window.addEventListener('message', function (event) {
  2028. if (event.data.tag == _this.tag && event.data.conn_tag == _this.connTag && event.data.source == "server") {
  2029. _this.recvCallback && _this.recvCallback(event.data.msg);
  2030. }
  2031. });
  2032. };
  2033. chromeClientMessage.prototype.Send = function (msg) {
  2034. window.postMessage({ tag: this.tag, conn_tag: this.connTag, msg: msg, source: this.source }, '*');
  2035. };
  2036. return chromeClientMessage;
  2037. }(msg));
  2038. /***/ }),
  2039. /***/ "./src/internal/utils/utils.ts":
  2040. /*!*************************************!*\
  2041. !*** ./src/internal/utils/utils.ts ***!
  2042. \*************************************/
  2043. /*! no static exports found */
  2044. /***/ (function(module, exports, __webpack_require__) {
  2045. "use strict";
  2046. Object.defineProperty(exports, "__esModule", { value: true });
  2047. 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;
  2048. var application_1 = __webpack_require__(/*! ../application */ "./src/internal/application.ts");
  2049. var HttpUtils = /** @class */ (function () {
  2050. function HttpUtils() {
  2051. }
  2052. HttpUtils.Request = function (info) {
  2053. if (application_1.Application.App.IsBackend) {
  2054. fetch(info.url, info).then(function (body) {
  2055. if (info.json) {
  2056. return body.json();
  2057. }
  2058. else {
  2059. return body.text();
  2060. }
  2061. }).then(function (body) {
  2062. info.success && info.success(body);
  2063. }).catch(function () {
  2064. info.error && info.error();
  2065. });
  2066. return;
  2067. }
  2068. HttpUtils.crossDomainRequest(info);
  2069. };
  2070. HttpUtils.errorCode = function (ret) {
  2071. if (!ret.code) {
  2072. return false;
  2073. }
  2074. switch (ret.code) {
  2075. case -1: {
  2076. application_1.Application.App.log.Info(ret.msg);
  2077. break;
  2078. }
  2079. case -2: {
  2080. application_1.Application.App.log.Warn(ret.msg);
  2081. break;
  2082. }
  2083. case 1: {
  2084. application_1.Application.App.log.Info(ret.msg);
  2085. return false;
  2086. }
  2087. default: {
  2088. return false;
  2089. }
  2090. }
  2091. return true;
  2092. };
  2093. HttpUtils.crossDomainRequest = function (info) {
  2094. if (window.hasOwnProperty('GM_xmlhttpRequest')) {
  2095. //兼容油猴
  2096. info.data = info.body;
  2097. info.onreadystatechange = function (response) {
  2098. if (response.readyState == 4) {
  2099. if (response.status == 200) {
  2100. if (info.json) {
  2101. var ret = JSON.parse(response.responseText);
  2102. if (HttpUtils.errorCode(ret)) {
  2103. info.error && info.error();
  2104. return;
  2105. }
  2106. info.success && info.success(ret);
  2107. }
  2108. else {
  2109. info.success && info.success(response.responseText);
  2110. }
  2111. }
  2112. else {
  2113. info.error && info.error();
  2114. }
  2115. }
  2116. };
  2117. window.GM_xmlhttpRequest(info);
  2118. }
  2119. else {
  2120. var client = application_1.Application.App.Client;
  2121. client.Recv(function (data) {
  2122. if (data.code == 0) {
  2123. if (info.json) {
  2124. if (HttpUtils.errorCode(data.body)) {
  2125. info.error && info.error();
  2126. return;
  2127. }
  2128. }
  2129. info.success && info.success(data.body);
  2130. }
  2131. else {
  2132. info.error && info.error();
  2133. }
  2134. });
  2135. client.Send({
  2136. type: "GM_xmlhttpRequest", info: {
  2137. url: info.url,
  2138. method: info.method,
  2139. json: info.json,
  2140. body: info.body,
  2141. headers: info.headers,
  2142. }
  2143. });
  2144. }
  2145. };
  2146. HttpUtils.HttpGet = function (url, info) {
  2147. info.url = url;
  2148. this.Request(info);
  2149. };
  2150. HttpUtils.HttpPost = function (url, body, info) {
  2151. info.url = url;
  2152. info.body = body;
  2153. if (!info.headers) {
  2154. info.headers = {};
  2155. }
  2156. if (!info.headers["Content-Type"]) {
  2157. info.headers["Content-Type"] = "application/x-www-form-urlencoded";
  2158. }
  2159. info.method = "POST";
  2160. this.Request(info);
  2161. };
  2162. HttpUtils.SendRequest = function (client, data) {
  2163. if (!data.info) {
  2164. return;
  2165. }
  2166. var info = data.info;
  2167. if (application_1.Application.App.IsBackend) {
  2168. info.success = function (body) {
  2169. client.Send({ body: body, code: 0 });
  2170. };
  2171. info.error = function () {
  2172. client.Send({ code: -1 });
  2173. };
  2174. HttpUtils.Request(info);
  2175. }
  2176. else {
  2177. // content 做转发
  2178. var extClient = application_1.Application.App.Client;
  2179. extClient.Send({ type: "GM_xmlhttpRequest", info: info });
  2180. extClient.Recv(function (data) {
  2181. client.Send(data);
  2182. });
  2183. }
  2184. };
  2185. return HttpUtils;
  2186. }());
  2187. exports.HttpUtils = HttpUtils;
  2188. /**
  2189. * 通过源码注入js资源
  2190. * @param doc
  2191. * @param url
  2192. * @constructor
  2193. */
  2194. function Injected(doc, source) {
  2195. var temp = doc.createElement('script');
  2196. temp.setAttribute('type', 'text/javascript');
  2197. temp.innerHTML = source;
  2198. temp.className = "injected-js";
  2199. doc.documentElement.appendChild(temp);
  2200. return temp;
  2201. }
  2202. exports.Injected = Injected;
  2203. /**
  2204. * 通过源码注入js资源
  2205. * @param doc
  2206. * @param url
  2207. * @constructor
  2208. */
  2209. function InjectedBySrc(doc, source) {
  2210. var temp = doc.createElement('script');
  2211. temp.setAttribute('type', 'text/javascript');
  2212. temp.src = source;
  2213. temp.className = "injected-js";
  2214. doc.documentElement.appendChild(temp);
  2215. return temp;
  2216. }
  2217. exports.InjectedBySrc = InjectedBySrc;
  2218. function syncGetChromeStorageLocal(key) {
  2219. return new Promise(function (resolve) { return (chrome.storage.local.get(key, function (value) {
  2220. resolve(value[key]);
  2221. })); });
  2222. }
  2223. exports.syncGetChromeStorageLocal = syncGetChromeStorageLocal;
  2224. function syncSetChromeStorageLocal(key, value) {
  2225. var tmp = {};
  2226. tmp[key] = value;
  2227. return new Promise(function (resolve) { return (chrome.storage.local.set(tmp, function () {
  2228. resolve();
  2229. })); });
  2230. }
  2231. exports.syncSetChromeStorageLocal = syncSetChromeStorageLocal;
  2232. /**
  2233. * 移除注入js
  2234. * @param doc
  2235. */
  2236. function RemoveInjected(doc) {
  2237. var resource = doc.getElementsByClassName("injected-js");
  2238. for (var i = 0; i < resource.length; i++) {
  2239. resource[i].remove();
  2240. }
  2241. }
  2242. exports.RemoveInjected = RemoveInjected;
  2243. function randNumber(minNum, maxNum) {
  2244. return Math.floor(Math.random() * (maxNum - minNum + 1) + minNum);
  2245. }
  2246. exports.randNumber = randNumber;
  2247. /**
  2248. * 创建一个按钮
  2249. * @param title
  2250. * @param description
  2251. * @param id
  2252. */
  2253. function createBtn(title, description, className, id) {
  2254. if (description === void 0) { description = ""; }
  2255. if (className === void 0) { className = ""; }
  2256. if (id === void 0) { id = ""; }
  2257. var btn = document.createElement('button');
  2258. btn.innerText = title;
  2259. btn.id = id;
  2260. btn.title = description;
  2261. btn.className = className;
  2262. return btn;
  2263. }
  2264. exports.createBtn = createBtn;
  2265. /**
  2266. * get请求
  2267. * @param {*} url
  2268. */
  2269. function get(url, success) {
  2270. var xmlhttp = createRequest();
  2271. xmlhttp.open("GET", url, true);
  2272. xmlhttp.onreadystatechange = function () {
  2273. if (this.readyState == 4) {
  2274. if (this.status == 200) {
  2275. success && success(this.responseText, this.resource);
  2276. }
  2277. else {
  2278. xmlhttp.errorCallback && xmlhttp.errorCallback(this);
  2279. }
  2280. }
  2281. };
  2282. xmlhttp.send();
  2283. return xmlhttp;
  2284. }
  2285. exports.get = get;
  2286. /**
  2287. * post请求
  2288. * @param {*} url
  2289. * @param {*} data
  2290. * @param {*} json
  2291. */
  2292. function post(url, data, json, success) {
  2293. if (json === void 0) { json = true; }
  2294. var xmlhttp = createRequest();
  2295. xmlhttp.open("POST", url, true);
  2296. if (json) {
  2297. xmlhttp.setRequestHeader("Content-Type", "application/json");
  2298. }
  2299. else {
  2300. xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  2301. }
  2302. xmlhttp.onreadystatechange = function () {
  2303. if (this.readyState == 4) {
  2304. if (this.status == 200) {
  2305. success && success(this.responseText);
  2306. }
  2307. else {
  2308. xmlhttp.errorCallback && xmlhttp.errorCallback(this);
  2309. }
  2310. }
  2311. };
  2312. xmlhttp.send(data);
  2313. return xmlhttp;
  2314. }
  2315. exports.post = post;
  2316. /**
  2317. * 创建http请求
  2318. */
  2319. function createRequest() {
  2320. var xmlhttp;
  2321. if (window.XMLHttpRequest) {
  2322. xmlhttp = new XMLHttpRequest();
  2323. }
  2324. else {
  2325. xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  2326. }
  2327. xmlhttp.error = function (callback) {
  2328. xmlhttp.errorCallback = callback;
  2329. return xmlhttp;
  2330. };
  2331. xmlhttp.withCredentials = true;
  2332. return xmlhttp;
  2333. }
  2334. // 移除html tag
  2335. function removeHTMLTag(html) {
  2336. var revHtml = /<.*?>/g;
  2337. html = html.replace(revHtml, '');
  2338. html = html.replace(/(^\s+)|(\s+$)/g, '');
  2339. return html;
  2340. }
  2341. exports.removeHTMLTag = removeHTMLTag;
  2342. /**
  2343. * 去除html标签和处理中文
  2344. * @param {string} html
  2345. */
  2346. function removeHTML(html) {
  2347. //先处理带src和href属性的标签
  2348. var srcReplace = /<img.*?src="(.*?)".*?>/g;
  2349. html = html.replace(srcReplace, '$1');
  2350. srcReplace = /(<iframe.+?>)\s+?(<\/iframe>)/g;
  2351. html = html.replace(srcReplace, '$1$2');
  2352. srcReplace = /<(iframe|a).*?(src|href)="(.*?)".*?>(.*?)<\/(iframe|a)>/g;
  2353. html = html.replace(srcReplace, '$3$4');
  2354. var revHtml = /<.*?>/g;
  2355. html = html.replace(revHtml, '');
  2356. html = html.replace(/(^\s+)|(\s+$)/g, '');
  2357. html = dealSymbol(html);
  2358. return html.replace(/&nbsp;/g, ' ')
  2359. .replace(/&quot;/g, "\"").replace(/&gt;/g, ">")
  2360. .replace(/&lt;/g, "<").replace(/&amp;/g, '&').trim();
  2361. }
  2362. exports.removeHTML = removeHTML;
  2363. /**
  2364. * 处理符号
  2365. * @param topic
  2366. */
  2367. function dealSymbol(topic) {
  2368. topic = topic.replace(/,/g, ',');
  2369. topic = topic.replace(/(/g, '(');
  2370. topic = topic.replace(/)/g, ')');
  2371. topic = topic.replace(/?/g, '?');
  2372. topic = topic.replace(/:/g, ':');
  2373. topic = topic.replace(/。/g, '.');
  2374. topic = topic.replace(/[“”]/g, '"');
  2375. return topic;
  2376. }
  2377. /**
  2378. * 取中间文本
  2379. * @param str
  2380. * @param left
  2381. * @param right
  2382. */
  2383. function substrex(str, left, right) {
  2384. var leftPos = str.indexOf(left) + left.length;
  2385. var rightPos = str.indexOf(right, leftPos);
  2386. return str.substring(leftPos, rightPos);
  2387. }
  2388. exports.substrex = substrex;
  2389. function dealHotVersion(hotversion) {
  2390. hotversion = hotversion.substring(0, hotversion.indexOf(".") + 1) + hotversion.substring(hotversion.indexOf(".") + 1).replace(".", "");
  2391. return Number(hotversion);
  2392. }
  2393. exports.dealHotVersion = dealHotVersion;
  2394. function protocolPrompt(content, key, keyword) {
  2395. keyword = keyword || "yes";
  2396. if (localStorage[key] == undefined || localStorage[key] != 1) {
  2397. var msg = prompt(content + "\n如果以后不想再弹出本对话框并且同意请在下方填写\"" + keyword + "\"");
  2398. if (msg === null)
  2399. return false;
  2400. if (keyword != msg) {
  2401. return false;
  2402. }
  2403. localStorage[key] = 1;
  2404. }
  2405. return true;
  2406. }
  2407. exports.protocolPrompt = protocolPrompt;
  2408. function getImageBase64(img, ext) {
  2409. var canvas = document.createElement("canvas");
  2410. canvas.width = img.width;
  2411. canvas.height = img.height;
  2412. var ctx = canvas.getContext("2d");
  2413. ctx.drawImage(img, 0, 0, img.width, img.height);
  2414. var dataURL = canvas.toDataURL("image/" + ext, 0.75); //节省可怜的流量>_<,虽然好像没有啥
  2415. canvas = null;
  2416. return dataURL;
  2417. }
  2418. exports.getImageBase64 = getImageBase64;
  2419. function isPhone() {
  2420. return /Android|iPhone/i.test(navigator.userAgent);
  2421. }
  2422. exports.isPhone = isPhone;
  2423. function Noifications(details) {
  2424. if (window.hasOwnProperty("GM_notification")) {
  2425. window.GM_notification(details);
  2426. }
  2427. else {
  2428. var client = application_1.Application.App.Client;
  2429. client.Send({
  2430. type: "GM_notification", details: details,
  2431. });
  2432. application_1.Application.App.Client.Send(details);
  2433. }
  2434. }
  2435. exports.Noifications = Noifications;
  2436. function toBool(val) {
  2437. if (typeof val == "boolean") {
  2438. return val;
  2439. }
  2440. return val == "true";
  2441. }
  2442. exports.toBool = toBool;
  2443. function boolToString(val) {
  2444. if (val) {
  2445. return "true";
  2446. }
  2447. return "false";
  2448. }
  2449. exports.boolToString = boolToString;
  2450. function UntrustedClick(el) {
  2451. if (window.CAT_click != undefined) {
  2452. CAT_click(el);
  2453. return true;
  2454. }
  2455. var untrusted = new MouseEvent("click", { "clientX": 10086 });
  2456. if (!untrusted.isTrusted) {
  2457. application_1.Application.App.log.Warn("扩展执行错误");
  2458. return false;
  2459. }
  2460. return el.dispatchEvent(untrusted);
  2461. }
  2462. exports.UntrustedClick = UntrustedClick;
  2463. function Sleep(timeout) {
  2464. return new Promise(function (resolve) {
  2465. setTimeout(function () {
  2466. resolve(undefined);
  2467. }, timeout);
  2468. });
  2469. }
  2470. exports.Sleep = Sleep;
  2471. /***/ }),
  2472. /***/ "./src/mooc/chaoxing/course.ts":
  2473. /*!*************************************!*\
  2474. !*** ./src/mooc/chaoxing/course.ts ***!
  2475. \*************************************/
  2476. /*! no static exports found */
  2477. /***/ (function(module, exports, __webpack_require__) {
  2478. "use strict";
  2479. var __extends = (this && this.__extends) || (function () {
  2480. var extendStatics = function (d, b) {
  2481. extendStatics = Object.setPrototypeOf ||
  2482. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2483. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2484. return extendStatics(d, b);
  2485. };
  2486. return function (d, b) {
  2487. extendStatics(d, b);
  2488. function __() { this.constructor = d; }
  2489. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2490. };
  2491. })();
  2492. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  2493. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  2494. return new (P || (P = Promise))(function (resolve, reject) {
  2495. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  2496. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  2497. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  2498. step((generator = generator.apply(thisArg, _arguments || [])).next());
  2499. });
  2500. };
  2501. var __generator = (this && this.__generator) || function (thisArg, body) {
  2502. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  2503. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  2504. function verb(n) { return function (v) { return step([n, v]); }; }
  2505. function step(op) {
  2506. if (f) throw new TypeError("Generator is already executing.");
  2507. while (_) try {
  2508. 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;
  2509. if (y = 0, t) op = [op[0] & 2, t.value];
  2510. switch (op[0]) {
  2511. case 0: case 1: t = op; break;
  2512. case 4: _.label++; return { value: op[1], done: false };
  2513. case 5: _.label++; y = op[1]; op = [0]; continue;
  2514. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  2515. default:
  2516. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  2517. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  2518. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  2519. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  2520. if (t[2]) _.ops.pop();
  2521. _.trys.pop(); continue;
  2522. }
  2523. op = body.call(thisArg, _);
  2524. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  2525. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  2526. }
  2527. };
  2528. Object.defineProperty(exports, "__esModule", { value: true });
  2529. exports.CxHomeWork = exports.CxExamTopic = exports.CxCourse = void 0;
  2530. var application_1 = __webpack_require__(/*! @App/internal/application */ "./src/internal/application.ts");
  2531. var factory_1 = __webpack_require__(/*! @App/mooc/chaoxing/factory */ "./src/mooc/chaoxing/factory.ts");
  2532. var event_1 = __webpack_require__(/*! @App/internal/utils/event */ "./src/internal/utils/event.ts");
  2533. //课程任务
  2534. var CxCourse = /** @class */ (function (_super) {
  2535. __extends(CxCourse, _super);
  2536. function CxCourse() {
  2537. var _this = _super !== null && _super.apply(this, arguments) || this;
  2538. _this.taskIndex = 0;
  2539. return _this;
  2540. }
  2541. CxCourse.prototype.Init = function () {
  2542. var _this = this;
  2543. return new Promise(function (resolve) {
  2544. var first = true;
  2545. document.addEventListener("load", function (ev) {
  2546. var el = (ev.srcElement || ev.target);
  2547. if (el.id == "iframe") {
  2548. application_1.Application.App.log.Info("超星新窗口加载");
  2549. _this.OperateCard(el);
  2550. // 超星会有多次加载,所以使用一个flag变量,只回调一次
  2551. first && resolve(undefined);
  2552. first = false;
  2553. }
  2554. }, true);
  2555. });
  2556. };
  2557. CxCourse.prototype.Stop = function () {
  2558. throw new Error("Method not implemented.");
  2559. };
  2560. CxCourse.prototype.Next = function () {
  2561. var _this = this;
  2562. return new Promise(function (resolve) {
  2563. if (_this.taskList.length > _this.taskIndex) {
  2564. resolve(_this.taskList[_this.taskIndex]);
  2565. return _this.taskIndex++;
  2566. }
  2567. // 当页任务点全部结束,翻页.由于会重新加载窗口调用reload,在加载完成之后再返回任务点.(本方法是同步调用,所以使用此种方法)
  2568. _this.addEventListenerOnce("reload", function () { return __awaiter(_this, void 0, void 0, function () {
  2569. var _a;
  2570. return __generator(this, function (_b) {
  2571. switch (_b.label) {
  2572. case 0:
  2573. _a = resolve;
  2574. return [4 /*yield*/, this.Next()];
  2575. case 1:
  2576. _a.apply(void 0, [_b.sent()]);
  2577. return [2 /*return*/];
  2578. }
  2579. });
  2580. }); });
  2581. _this.nextPage(null);
  2582. });
  2583. };
  2584. CxCourse.prototype.SetTaskPointer = function (index) {
  2585. this.taskIndex = index;
  2586. };
  2587. // 操作任务卡,一个页面会包含很多任务,取出来
  2588. CxCourse.prototype.OperateCard = function (iframe) {
  2589. return __awaiter(this, void 0, void 0, function () {
  2590. var iframeWindow, match, _loop_1, this_1, index;
  2591. var _this = this;
  2592. return __generator(this, function (_a) {
  2593. switch (_a.label) {
  2594. case 0:
  2595. iframeWindow = iframe.contentWindow;
  2596. // 判断任务的参数
  2597. if (iframeWindow.mArg == undefined) {
  2598. match = iframeWindow.document.body.innerHTML.match(/try{\s+?mArg = (.*?);/);
  2599. if (!match) {
  2600. return [2 /*return*/];
  2601. }
  2602. iframeWindow.mArg = JSON.parse(match[1]);
  2603. }
  2604. // 任务的属性
  2605. this.attachments = iframeWindow.mArg.attachments;
  2606. this.taskList = new Array();
  2607. _loop_1 = function (index) {
  2608. var value, task;
  2609. return __generator(this, function (_a) {
  2610. switch (_a.label) {
  2611. case 0:
  2612. value = this_1.attachments[index];
  2613. value.defaults = iframeWindow.mArg.defaults;
  2614. // 任务工厂去创建对应的任务对象
  2615. task = factory_1.TaskFactory.CreateCourseTask(iframeWindow, value);
  2616. if (!task) {
  2617. return [2 /*return*/, "continue"];
  2618. }
  2619. task.jobIndex = index;
  2620. this_1.taskList.push(task);
  2621. task.addEventListener("complete", function () {
  2622. _this.callEvent("taskComplete", index, task);
  2623. });
  2624. return [4 /*yield*/, task.Init()];
  2625. case 1:
  2626. _a.sent();
  2627. return [2 /*return*/];
  2628. }
  2629. });
  2630. };
  2631. this_1 = this;
  2632. index = 0;
  2633. _a.label = 1;
  2634. case 1:
  2635. if (!(index < this.attachments.length)) return [3 /*break*/, 4];
  2636. return [5 /*yield**/, _loop_1(index)];
  2637. case 2:
  2638. _a.sent();
  2639. _a.label = 3;
  2640. case 3:
  2641. index++;
  2642. return [3 /*break*/, 1];
  2643. case 4:
  2644. this.taskIndex = 0;
  2645. this.callEvent("reload");
  2646. return [2 /*return*/];
  2647. }
  2648. });
  2649. });
  2650. };
  2651. CxCourse.prototype.afterPage = function () {
  2652. //感觉奇葩的方法...
  2653. var els = document.querySelectorAll("div.ncells > *:not(.currents) > .orange01");
  2654. var now = document.querySelector("div.ncells > .currents");
  2655. for (var i = 0; i < els.length; i++) {
  2656. if (now.getBoundingClientRect().top < els[i].getBoundingClientRect().top) {
  2657. return els[i];
  2658. }
  2659. }
  2660. return null;
  2661. };
  2662. CxCourse.prototype.nextPage = function (num) {
  2663. var _this = this;
  2664. var el = document.querySelector("span.currents ~ span") || document.querySelector(".prev_next.next");
  2665. if (el != undefined) {
  2666. return el.click();
  2667. }
  2668. //只往后执行
  2669. el = this.afterPage();
  2670. if (el == undefined) {
  2671. //进行有锁任务查找
  2672. if (document.querySelector("div.ncells > *:not(.currents) > .lock") == undefined) {
  2673. return this.callEvent("complete");
  2674. }
  2675. return setTimeout(function () {
  2676. if (num > 5) {
  2677. return _this.callEvent("error", "被锁卡住了,请手动处理");
  2678. }
  2679. application_1.Application.App.log.Info("等待解锁");
  2680. _this.nextPage(num + 1);
  2681. }, 5000);
  2682. }
  2683. el.parentElement.querySelector("a>span").click();
  2684. };
  2685. return CxCourse;
  2686. }(event_1.EventListener));
  2687. exports.CxCourse = CxCourse;
  2688. // 考试
  2689. var CxExamTopic = /** @class */ (function () {
  2690. function CxExamTopic() {
  2691. }
  2692. CxExamTopic.prototype.Init = function () {
  2693. window.addEventListener("load", function () {
  2694. var el = document.querySelector("#paperId");
  2695. var info = "0";
  2696. if (el) {
  2697. info = el.value;
  2698. }
  2699. var task = factory_1.TaskFactory.CreateExamTopicTask(window, {
  2700. refer: document.URL,
  2701. id: "exam-" + info,
  2702. info: info,
  2703. });
  2704. task.Init();
  2705. if (document.URL.indexOf("exam/test/reVersionTestStartNew") > 0) {
  2706. if (application_1.Application.App.config.auto) {
  2707. task.Start();
  2708. }
  2709. }
  2710. });
  2711. };
  2712. return CxExamTopic;
  2713. }());
  2714. exports.CxExamTopic = CxExamTopic;
  2715. // 作业
  2716. var CxHomeWork = /** @class */ (function () {
  2717. function CxHomeWork() {
  2718. }
  2719. CxHomeWork.prototype.Init = function () {
  2720. window.onload = function () {
  2721. var el = document.querySelector("#workLibraryId");
  2722. var info = "";
  2723. if (el) {
  2724. info = el.value;
  2725. }
  2726. var task = factory_1.TaskFactory.CreateHomeworkTopicTask(window, {
  2727. refer: document.URL,
  2728. id: info,
  2729. info: info,
  2730. });
  2731. task.Init();
  2732. if (application_1.Application.App.config.auto && document.querySelector("#workLibraryId")) {
  2733. task.Start();
  2734. }
  2735. };
  2736. };
  2737. return CxHomeWork;
  2738. }());
  2739. exports.CxHomeWork = CxHomeWork;
  2740. /***/ }),
  2741. /***/ "./src/mooc/chaoxing/factory.ts":
  2742. /*!**************************************!*\
  2743. !*** ./src/mooc/chaoxing/factory.ts ***!
  2744. \**************************************/
  2745. /*! no static exports found */
  2746. /***/ (function(module, exports, __webpack_require__) {
  2747. "use strict";
  2748. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  2749. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  2750. return new (P || (P = Promise))(function (resolve, reject) {
  2751. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  2752. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  2753. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  2754. step((generator = generator.apply(thisArg, _arguments || [])).next());
  2755. });
  2756. };
  2757. var __generator = (this && this.__generator) || function (thisArg, body) {
  2758. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  2759. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  2760. function verb(n) { return function (v) { return step([n, v]); }; }
  2761. function step(op) {
  2762. if (f) throw new TypeError("Generator is already executing.");
  2763. while (_) try {
  2764. 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;
  2765. if (y = 0, t) op = [op[0] & 2, t.value];
  2766. switch (op[0]) {
  2767. case 0: case 1: t = op; break;
  2768. case 4: _.label++; return { value: op[1], done: false };
  2769. case 5: _.label++; y = op[1]; op = [0]; continue;
  2770. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  2771. default:
  2772. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  2773. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  2774. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  2775. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  2776. if (t[2]) _.ops.pop();
  2777. _.trys.pop(); continue;
  2778. }
  2779. op = body.call(thisArg, _);
  2780. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  2781. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  2782. }
  2783. };
  2784. Object.defineProperty(exports, "__esModule", { value: true });
  2785. exports.TaskFactory = void 0;
  2786. var video_1 = __webpack_require__(/*! @App/mooc/chaoxing/video */ "./src/mooc/chaoxing/video.ts");
  2787. var topic_1 = __webpack_require__(/*! @App/mooc/chaoxing/topic */ "./src/mooc/chaoxing/topic.ts");
  2788. var question_1 = __webpack_require__(/*! @App/internal/app/question */ "./src/internal/app/question.ts");
  2789. var question_2 = __webpack_require__(/*! @App/mooc/chaoxing/question */ "./src/mooc/chaoxing/question.ts");
  2790. var application_1 = __webpack_require__(/*! @App/internal/application */ "./src/internal/application.ts");
  2791. var task_1 = __webpack_require__(/*! @App/mooc/chaoxing/task */ "./src/mooc/chaoxing/task.ts");
  2792. var utils_1 = __webpack_require__(/*! @App/mooc/chaoxing/utils */ "./src/mooc/chaoxing/utils.ts");
  2793. var utils_2 = __webpack_require__(/*! @App/internal/utils/utils */ "./src/internal/utils/utils.ts");
  2794. var special_1 = __webpack_require__(/*! @App/mooc/chaoxing/special */ "./src/mooc/chaoxing/special.ts");
  2795. // 任务工厂,创建对应的任务
  2796. var TaskFactory = /** @class */ (function () {
  2797. function TaskFactory() {
  2798. }
  2799. TaskFactory.CreateCourseTask = function (context, taskinfo) {
  2800. if (taskinfo.property.module == "insertaudio") {
  2801. taskinfo.type = "audio";
  2802. }
  2803. //TODO:优化
  2804. if (taskinfo.type != "video" && taskinfo.type != "workid" && taskinfo.type != "document"
  2805. && taskinfo.type != "audio") {
  2806. return null;
  2807. }
  2808. var task;
  2809. var taskIframe = context.document.querySelector("iframe[jobid='" + taskinfo.jobid + "']");
  2810. var prev;
  2811. if (taskIframe == undefined) {
  2812. taskIframe = context.document.querySelector("iframe[data*='" + taskinfo.property.mid + "'],iframe[objectid='" + taskinfo.property.objectid + "']");
  2813. prev = document.createElement("div");
  2814. taskIframe.parentElement.prepend(prev);
  2815. }
  2816. else {
  2817. prev = taskIframe.previousElementSibling;
  2818. }
  2819. switch (taskinfo.type) {
  2820. case "video": {
  2821. var bar = new video_1.CxVideoControlBar(prev, new video_1.Video(taskIframe.contentWindow, taskinfo));
  2822. task = bar.task;
  2823. task.muted = application_1.Application.App.config.video_mute;
  2824. task.playbackRate = application_1.Application.App.config.video_multiple;
  2825. break;
  2826. }
  2827. case "workid": {
  2828. var contentWindow = taskIframe.contentWindow.document.querySelector("#frame_content").contentWindow;
  2829. taskinfo.refer = context.document.URL;
  2830. taskinfo.id = taskinfo.property.workid;
  2831. taskinfo.info = taskinfo.property.workid;
  2832. var topic = new topic_1.CxCourseTopic(contentWindow, new question_1.ToolsQuestionBankFacade("cx", {
  2833. refer: context.document.URL,
  2834. id: taskinfo.property.workid, info: taskinfo.property.workid,
  2835. }));
  2836. topic.SetQueryQuestions(new topic_1.CxCourseQueryQuestion(contentWindow, function (context, el) {
  2837. return question_2.CxQuestionFactory.CreateCourseQuestion(context, el);
  2838. }));
  2839. var bar = new topic_1.CxTopicControlBar(prev, new topic_1.TopicAdapter(context, taskinfo, topic));
  2840. if (application_1.Application.App.config.answer_ignore) {
  2841. return null;
  2842. }
  2843. task = bar.task;
  2844. break;
  2845. }
  2846. case "document": {
  2847. var bar = new task_1.CxTaskControlBar(prev, new special_1.CxDocumentTask(taskIframe.contentWindow, taskinfo));
  2848. // bar.append(bar.download());
  2849. task = bar.task;
  2850. task.muted = application_1.Application.App.config.video_mute;
  2851. task.playbackRate = application_1.Application.App.config.video_multiple;
  2852. break;
  2853. }
  2854. case "audio": {
  2855. var bar = new special_1.CxAudioControlBar(prev, new special_1.CxAudioTask(taskIframe.contentWindow, taskinfo));
  2856. task = bar.task;
  2857. task.muted = application_1.Application.App.config.video_mute;
  2858. task.playbackRate = application_1.Application.App.config.video_multiple;
  2859. break;
  2860. }
  2861. default:
  2862. return null;
  2863. }
  2864. return task;
  2865. };
  2866. TaskFactory.CreateExamTopicTask = function (context, taskinfo) {
  2867. var topic = new topic_1.ExamTopic(context, new question_1.ToolsQuestionBankFacade("cx", taskinfo));
  2868. var task = new topic_1.TopicAdapter(context, taskinfo, topic);
  2869. if (document.URL.indexOf("exam/test/reVersionTestStartNew") > 0) {
  2870. topic.SetQueryQuestions(topic);
  2871. var btn_1 = utils_1.CssBtn(utils_2.createBtn("搜索答案", "搜索题目答案"));
  2872. document.querySelector(".Cy_ulBottom.clearfix.w-buttom,.Cy_ulTk,.Cy_ulBottom.clearfix").append(btn_1);
  2873. btn_1.onclick = function () {
  2874. btn_1.innerText = "答案搜索中...";
  2875. try {
  2876. task.Start().then(function (ret) {
  2877. ret = ret || "搜索题目";
  2878. btn_1.innerText = question_1.QuestionStatusString(ret);
  2879. });
  2880. }
  2881. catch (e) {
  2882. }
  2883. return false;
  2884. };
  2885. }
  2886. else {
  2887. topic.SetQueryQuestions(new topic_1.CxCourseQueryQuestion(context, function (context, el) {
  2888. return question_2.CxQuestionFactory.CreateExamCollectQuestion(context, el);
  2889. }));
  2890. }
  2891. return task;
  2892. };
  2893. TaskFactory.CreateHomeworkTopicTask = function (context, taskinfo) {
  2894. var _this = this;
  2895. var bank = new question_1.ToolsQuestionBankFacade("cx", taskinfo);
  2896. var topic = new topic_1.HomeworkTopic(context, bank);
  2897. topic.SetQueryQuestions(new topic_1.CxCourseQueryQuestion(context, function (context, el) {
  2898. return question_2.CxQuestionFactory.CreateHomeWorkQuestion(context, el);
  2899. }));
  2900. var task = new topic_1.TopicAdapter(context, taskinfo, topic);
  2901. var btn = utils_1.CssBtn(utils_2.createBtn("搜索答案", "搜索题目答案"));
  2902. if (document.querySelector("input#workRelationId")) {
  2903. document.querySelector(".CyTop").append(btn);
  2904. btn.onclick = function () { return __awaiter(_this, void 0, void 0, function () {
  2905. return __generator(this, function (_a) {
  2906. btn.innerText = "答案搜索中...";
  2907. task.Start().then(function (ret) {
  2908. ret = ret || "搜索题目";
  2909. btn.innerText = question_1.QuestionStatusString(ret);
  2910. });
  2911. return [2 /*return*/];
  2912. });
  2913. }); };
  2914. }
  2915. return task;
  2916. };
  2917. return TaskFactory;
  2918. }());
  2919. exports.TaskFactory = TaskFactory;
  2920. /***/ }),
  2921. /***/ "./src/mooc/chaoxing/platform.ts":
  2922. /*!***************************************!*\
  2923. !*** ./src/mooc/chaoxing/platform.ts ***!
  2924. \***************************************/
  2925. /*! no static exports found */
  2926. /***/ (function(module, exports, __webpack_require__) {
  2927. "use strict";
  2928. Object.defineProperty(exports, "__esModule", { value: true });
  2929. exports.CxPlatform = void 0;
  2930. var vcode_1 = __webpack_require__(/*! @App/internal/app/vcode */ "./src/internal/app/vcode.ts");
  2931. var course_1 = __webpack_require__(/*! ./course */ "./src/mooc/chaoxing/course.ts");
  2932. var vcode_2 = __webpack_require__(/*! ./vcode */ "./src/mooc/chaoxing/vcode.ts");
  2933. var video_1 = __webpack_require__(/*! ./video */ "./src/mooc/chaoxing/video.ts");
  2934. var read_1 = __webpack_require__(/*! @App/mooc/chaoxing/read */ "./src/mooc/chaoxing/read.ts");
  2935. var special_1 = __webpack_require__(/*! @App/mooc/chaoxing/special */ "./src/mooc/chaoxing/special.ts");
  2936. var application_1 = __webpack_require__(/*! @App/internal/application */ "./src/internal/application.ts");
  2937. var CxPlatform = /** @class */ (function () {
  2938. function CxPlatform() {
  2939. }
  2940. CxPlatform.prototype.CreateMooc = function () {
  2941. var url = document.URL;
  2942. var mooc = null;
  2943. if (url.indexOf("mycourse/studentstudy?") > 0) {
  2944. new vcode_1.VCode(new vcode_2.CxCourseVCode()); //添加打码组件
  2945. mooc = new course_1.CxCourse();
  2946. }
  2947. else if (url.indexOf("ananas/modules/video/index.html") > 0) {
  2948. mooc = new video_1.CxVideoOptimization();
  2949. }
  2950. else if (url.indexOf("ananas/modules/audio/index.html") > 0) {
  2951. mooc = new special_1.CxAudioOptimization();
  2952. }
  2953. else if ((url.indexOf("work/doHomeWorkNew") > 0 || url.indexOf("work/selectWorkQuestionYiPiYue") > 0) && self == top) {
  2954. mooc = new course_1.CxHomeWork();
  2955. }
  2956. else if (url.indexOf("exam/test/reVersionTestStartNew") > 0 || url.indexOf("exam/test/reVersionPaperMarkContentNew") > 0) {
  2957. mooc = new course_1.CxExamTopic();
  2958. }
  2959. else if (url.indexOf("/course/") > 0) {
  2960. mooc = new read_1.ReadStartPage();
  2961. }
  2962. else if (url.indexOf("ztnodedetailcontroller/visitnodedetail") > 0) {
  2963. mooc = new read_1.Read();
  2964. }
  2965. else if (url.indexOf("exam/test?") > 0) {
  2966. mooc = new read_1.Exam();
  2967. }
  2968. if (mooc) {
  2969. application_1.Application.App.config.SetNamespace("cx");
  2970. }
  2971. return mooc;
  2972. };
  2973. return CxPlatform;
  2974. }());
  2975. exports.CxPlatform = CxPlatform;
  2976. /***/ }),
  2977. /***/ "./src/mooc/chaoxing/question.ts":
  2978. /*!***************************************!*\
  2979. !*** ./src/mooc/chaoxing/question.ts ***!
  2980. \***************************************/
  2981. /*! no static exports found */
  2982. /***/ (function(module, exports, __webpack_require__) {
  2983. "use strict";
  2984. var __extends = (this && this.__extends) || (function () {
  2985. var extendStatics = function (d, b) {
  2986. extendStatics = Object.setPrototypeOf ||
  2987. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2988. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2989. return extendStatics(d, b);
  2990. };
  2991. return function (d, b) {
  2992. extendStatics(d, b);
  2993. function __() { this.constructor = d; }
  2994. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2995. };
  2996. })();
  2997. Object.defineProperty(exports, "__esModule", { value: true });
  2998. exports.CxQuestionFactory = void 0;
  2999. var utils_1 = __webpack_require__(/*! @App/internal/utils/utils */ "./src/internal/utils/utils.ts");
  3000. var question_1 = __webpack_require__(/*! @App/internal/app/question */ "./src/internal/app/question.ts");
  3001. var utils_2 = __webpack_require__(/*! ./utils */ "./src/mooc/chaoxing/utils.ts");
  3002. //TODO: 优化
  3003. var CxQuestionFactory = /** @class */ (function () {
  3004. function CxQuestionFactory() {
  3005. }
  3006. CxQuestionFactory.CreateCourseQuestion = function (context, el) {
  3007. var ret = question_1.SwitchTopicType(utils_1.substrex(el.innerText, '【', '】'));
  3008. return this.CreateCourseQuestionByTopicType(context, ret, el);
  3009. };
  3010. CxQuestionFactory.CreateExamQuestion = function (context, type, el) {
  3011. var processor = new ExamQuestionProcessor();
  3012. var ret = null;
  3013. this.RemoveNotice(el);
  3014. switch (type) {
  3015. case 1:
  3016. case 2: {
  3017. ret = new cxExamSelectQuestion(context, el, type, processor);
  3018. break;
  3019. }
  3020. case 3: {
  3021. ret = new cxExamJudgeQuestion(context, el, type, processor);
  3022. break;
  3023. }
  3024. case 4: {
  3025. ret = new cxExamFillQuestion(context, el, type, processor);
  3026. break;
  3027. }
  3028. default: {
  3029. this.AddNotice(el, "不支持的类型");
  3030. return null;
  3031. }
  3032. }
  3033. return ret;
  3034. };
  3035. CxQuestionFactory.CreateCourseQuestionByTopicType = function (context, type, el) {
  3036. var ret = null;
  3037. var processor = new CourseQuestionProcessor();
  3038. this.RemoveNotice(el);
  3039. switch (type) {
  3040. case 1:
  3041. case 2: {
  3042. ret = new cxSelectQuestion(context, el, type, processor);
  3043. break;
  3044. }
  3045. case 3: {
  3046. ret = new cxJudgeQuestion(context, el, type, processor);
  3047. break;
  3048. }
  3049. case 4: {
  3050. ret = new cxFillQuestion(context, el, type, processor);
  3051. break;
  3052. }
  3053. default: {
  3054. this.AddNotice(el, "不支持的类型");
  3055. return null;
  3056. }
  3057. }
  3058. return ret;
  3059. };
  3060. CxQuestionFactory.getBeforeType = function (el) {
  3061. var before = el.previousElementSibling;
  3062. do {
  3063. if (before.className == "Cy_TItle1") {
  3064. return before;
  3065. }
  3066. before = before.previousElementSibling;
  3067. } while (before != null);
  3068. return null;
  3069. };
  3070. CxQuestionFactory.CreateHomeWorkQuestion = function (context, el) {
  3071. var ret = CxQuestionFactory.getBeforeType(el);
  3072. return this.CreateCourseQuestionByTopicType(context, question_1.SwitchTopicType(utils_1.substrex(ret.innerText, ".", "(")), el);
  3073. };
  3074. //TODO:写的什么玩意啊
  3075. CxQuestionFactory.CreateExamCollectQuestion = function (context, el) {
  3076. var ret = CxQuestionFactory.getBeforeType(el.parentElement);
  3077. var txt = ret.innerText.match(/、(.*?)[\s|(]/)[1];
  3078. return this.CreateExamQuestionByTopicType(context, question_1.SwitchTopicType(txt), el);
  3079. };
  3080. CxQuestionFactory.CreateExamQuestionByTopicType = function (context, type, el) {
  3081. var ret = null;
  3082. var processor = new CourseQuestionProcessor();
  3083. this.RemoveNotice(el);
  3084. switch (type) {
  3085. case 1:
  3086. case 2: {
  3087. ret = new cxSelectQuestion(context, el, type, processor);
  3088. break;
  3089. }
  3090. case 3: {
  3091. ret = new cxJudgeQuestion(context, el, type, processor);
  3092. break;
  3093. }
  3094. case 4: {
  3095. ret = new cxExamFillQuestion(context, el, type, processor);
  3096. break;
  3097. }
  3098. default: {
  3099. this.AddNotice(el, "不支持的类型");
  3100. return null;
  3101. }
  3102. }
  3103. return ret;
  3104. };
  3105. CxQuestionFactory.RemoveNotice = function (el) {
  3106. var tmpel = el.querySelector(".clearfix > ul,.clearfix > .Py_tk,.Zy_ulTk");
  3107. if (tmpel == undefined) {
  3108. tmpel = el;
  3109. }
  3110. tmpel.querySelectorAll(".prompt-line-answer").forEach(function (v) {
  3111. v.remove();
  3112. });
  3113. };
  3114. CxQuestionFactory.AddNotice = function (el, str) {
  3115. var tmpel = el.querySelector(".clearfix > ul,.clearfix > .Py_tk,.Zy_ulTk");
  3116. if (tmpel == undefined) {
  3117. tmpel = el;
  3118. }
  3119. utils_2.CreateNoteLine(str, "answer", tmpel);
  3120. };
  3121. return CxQuestionFactory;
  3122. }());
  3123. exports.CxQuestionFactory = CxQuestionFactory;
  3124. var CourseQuestionProcessor = /** @class */ (function () {
  3125. function CourseQuestionProcessor() {
  3126. }
  3127. CourseQuestionProcessor.prototype.GetTopic = function (el) {
  3128. var ret = el.querySelector(".Zy_TItle > .clearfix,.Cy_TItle > .clearfix").innerHTML;
  3129. ret = ret.substring(ret.indexOf('】') + 1);
  3130. if (/((.+?)分)($|\s)/.test(ret)) {
  3131. ret = ret.substring(0, ret.lastIndexOf("("));
  3132. }
  3133. return ret;
  3134. };
  3135. return CourseQuestionProcessor;
  3136. }());
  3137. var ExamQuestionProcessor = /** @class */ (function () {
  3138. function ExamQuestionProcessor() {
  3139. }
  3140. ExamQuestionProcessor.prototype.GetTopic = function (el) {
  3141. var ret = el.querySelector(".Cy_TItle.clearfix .clearfix").innerHTML;
  3142. ret = ret.substr(0, ret.lastIndexOf('分)'));
  3143. ret = ret.substr(0, ret.lastIndexOf('('));
  3144. return ret;
  3145. };
  3146. return ExamQuestionProcessor;
  3147. }());
  3148. var cxQuestion = /** @class */ (function () {
  3149. function cxQuestion(context, el, type, processor) {
  3150. this.context = context;
  3151. this.el = el;
  3152. this.type = type;
  3153. this.processor = processor;
  3154. }
  3155. cxQuestion.prototype.SetStatus = function (status) {
  3156. this.AddNotice(question_1.TopicStatusString(status));
  3157. };
  3158. cxQuestion.prototype.GetTopic = function () {
  3159. return this.processor.GetTopic(this.el);
  3160. };
  3161. cxQuestion.prototype.RemoveNotice = function () {
  3162. CxQuestionFactory.RemoveNotice(this.el);
  3163. };
  3164. cxQuestion.prototype.AddNotice = function (str) {
  3165. CxQuestionFactory.AddNotice(this.el, str);
  3166. };
  3167. cxQuestion.prototype.GetType = function () {
  3168. return this.type;
  3169. };
  3170. cxQuestion.prototype.options = function () {
  3171. var tmpel = this.el.querySelector(".clearfix > ul,.clearfix ul.Zy_ulBottom.clearfix,ul.Zy_ulTk");
  3172. var list = tmpel.querySelectorAll("li");
  3173. return list;
  3174. };
  3175. cxQuestion.prototype.isCorrect = function () {
  3176. var el = this.el.querySelector(".Py_answer.clearfix,.Py_tk");
  3177. if (el) {
  3178. if (el.querySelectorAll('.fr.dui').length > 0 || el.querySelectorAll('.fr.bandui').length > 0) {
  3179. return el;
  3180. }
  3181. else if (el.innerHTML.indexOf('正确答案') >= 0) {
  3182. return el;
  3183. }
  3184. }
  3185. var topic = this.el.querySelector(".Cy_TItle.clearfix");
  3186. if (!topic) {
  3187. return null;
  3188. }
  3189. var fs = topic.querySelector(".font18.fb");
  3190. if (fs && fs.innerHTML != "0.0") {
  3191. return el;
  3192. }
  3193. return null;
  3194. };
  3195. cxQuestion.prototype.defaultAnswer = function () {
  3196. var ret = new question_1.PushAnswer();
  3197. ret.topic = this.GetTopic();
  3198. ret.type = this.GetType();
  3199. ret.correct = new Array();
  3200. ret.answers = new Array();
  3201. return ret;
  3202. };
  3203. return cxQuestion;
  3204. }());
  3205. var cxSelectQuestion = /** @class */ (function (_super) {
  3206. __extends(cxSelectQuestion, _super);
  3207. function cxSelectQuestion() {
  3208. return _super !== null && _super.apply(this, arguments) || this;
  3209. }
  3210. cxSelectQuestion.prototype.getContent = function (el) {
  3211. var ret = el.querySelector("a");
  3212. if (ret == null) {
  3213. var tmpel = el.querySelector("label > input,input");
  3214. if (tmpel.value == "true") {
  3215. return "对√";
  3216. }
  3217. return "错×";
  3218. }
  3219. return ret.innerHTML;
  3220. };
  3221. cxSelectQuestion.prototype.getOption = function (el) {
  3222. return el.querySelector("input").value;
  3223. };
  3224. cxSelectQuestion.prototype.click = function (el, content) {
  3225. var ipt = el.querySelector("label > input");
  3226. if (!ipt.checked) {
  3227. ipt.click();
  3228. }
  3229. this.AddNotice(this.getOption(el) + ":" + content);
  3230. };
  3231. cxSelectQuestion.prototype.Random = function () {
  3232. var options = this.options();
  3233. var pos = utils_1.randNumber(0, options.length - 1);
  3234. this.click(options[pos], this.getContent(options[pos]));
  3235. return "random";
  3236. };
  3237. cxSelectQuestion.prototype.Fill = function (s) {
  3238. var _this = this;
  3239. return new Promise(function (resolve) {
  3240. var options = _this.options();
  3241. var flag = false;
  3242. for (var i = 0; i < s.correct.length; i++) {
  3243. for (var j = 0; j < options.length; j++) {
  3244. if (s.correct[i].content.trim() == "") {
  3245. if (_this.getOption(options[j]) == s.correct[i].option) {
  3246. _this.click(options[j], _this.getContent(options[j]));
  3247. flag = true;
  3248. }
  3249. }
  3250. else if (s.Equal(_this.getContent(options[j]), s.correct[i].content)) {
  3251. _this.click(options[j], s.correct[i].content);
  3252. flag = true;
  3253. }
  3254. }
  3255. }
  3256. if (flag) {
  3257. return resolve("ok");
  3258. }
  3259. return resolve("no_match");
  3260. });
  3261. };
  3262. cxSelectQuestion.prototype.Correct = function () {
  3263. var correct = this.isCorrect();
  3264. if (correct == null) {
  3265. return null;
  3266. }
  3267. var ret = this.defaultAnswer();
  3268. var options = this.el.querySelectorAll(".Zy_ulTop > li.clearfix,.Cy_ulTop li");
  3269. var correctText = correct.querySelector("span").innerText;
  3270. for (var i = 0; i < options.length; i++) {
  3271. var optionText = options[i].querySelector("i.fl").innerText;
  3272. var option = {
  3273. option: optionText.substring(0, 1),
  3274. content: options[i].querySelector("a.fl,a").innerHTML,
  3275. };
  3276. ret.answers.push(option);
  3277. if (correctText.indexOf(option.option) > 0) {
  3278. ret.correct.push(option);
  3279. }
  3280. }
  3281. return ret;
  3282. };
  3283. return cxSelectQuestion;
  3284. }(cxQuestion));
  3285. var cxJudgeQuestion = /** @class */ (function (_super) {
  3286. __extends(cxJudgeQuestion, _super);
  3287. function cxJudgeQuestion() {
  3288. return _super !== null && _super.apply(this, arguments) || this;
  3289. }
  3290. cxJudgeQuestion.prototype.getContent = function (el) {
  3291. var tmpel = el.querySelector("label > input,input");
  3292. if (tmpel.value == "true") {
  3293. return "对√";
  3294. }
  3295. return "错×";
  3296. };
  3297. cxJudgeQuestion.prototype.click = function (el) {
  3298. var tmpel = el.querySelector("label > input,input");
  3299. if (!tmpel.checked) {
  3300. tmpel.click();
  3301. }
  3302. this.AddNotice(this.getContent(el));
  3303. };
  3304. cxJudgeQuestion.prototype.Random = function () {
  3305. var options = this.options();
  3306. var pos = utils_1.randNumber(0, 1);
  3307. this.click(options[pos]);
  3308. return "random";
  3309. };
  3310. cxJudgeQuestion.prototype.Fill = function (answer) {
  3311. var _this = this;
  3312. return new Promise(function (resolve) {
  3313. var options = _this.options();
  3314. _this.click(options[answer.correct[0].content ? 0 : 1]);
  3315. return resolve("ok");
  3316. });
  3317. };
  3318. cxJudgeQuestion.prototype.Correct = function () {
  3319. var el = this.el.querySelector(".Py_answer.clearfix");
  3320. var ret = this.defaultAnswer();
  3321. var score = this.el.querySelector(".Cy_TItle.clearfix .font18.fb");
  3322. if (el.innerHTML.indexOf('正确答案') !== -1 || (score && score.querySelector(".Cy_TItle.clearfix .font18.fb").innerHTML != "0.0")) {
  3323. var correctText_1 = el.querySelector("span").innerText;
  3324. if (correctText_1.indexOf('×') !== -1) {
  3325. ret.correct.push({ option: false, content: false });
  3326. }
  3327. else {
  3328. ret.correct.push({ option: true, content: true });
  3329. }
  3330. return ret;
  3331. }
  3332. if (!el.querySelectorAll('.fr.dui').length && !el.querySelectorAll('.fr.cuo').length) {
  3333. return null;
  3334. }
  3335. var correctText = el.querySelector("span").innerText;
  3336. if (el.querySelectorAll('.fr.dui').length) {
  3337. if (correctText.indexOf('×') !== -1) {
  3338. ret.correct.push({ option: false, content: false });
  3339. }
  3340. else {
  3341. ret.correct.push({ option: true, content: true });
  3342. }
  3343. }
  3344. else {
  3345. if (correctText.indexOf('×') !== -1) {
  3346. ret.correct.push({ option: true, content: true });
  3347. }
  3348. else {
  3349. ret.correct.push({ option: false, content: false });
  3350. }
  3351. }
  3352. return ret;
  3353. };
  3354. return cxJudgeQuestion;
  3355. }(cxSelectQuestion));
  3356. var cxFillQuestion = /** @class */ (function (_super) {
  3357. __extends(cxFillQuestion, _super);
  3358. function cxFillQuestion() {
  3359. return _super !== null && _super.apply(this, arguments) || this;
  3360. }
  3361. cxFillQuestion.prototype.getOption = function (el) {
  3362. if (el.className == "XztiHover1") {
  3363. return utils_1.substrex(el.previousElementSibling.innerHTML, "第", "空");
  3364. }
  3365. var tmpel = el.querySelector("span.fb");
  3366. return utils_1.substrex(tmpel.innerHTML, "第", "空");
  3367. };
  3368. cxFillQuestion.prototype.Random = function () {
  3369. return "no_support_random";
  3370. };
  3371. cxFillQuestion.prototype.Correct = function () {
  3372. var correct = this.isCorrect();
  3373. if (correct == null) {
  3374. return null;
  3375. }
  3376. var ret = this.defaultAnswer();
  3377. var options = this.el.querySelectorAll(".Py_tk span.font14");
  3378. var isMy = false;
  3379. if (options.length <= 0) {
  3380. isMy = true;
  3381. options = this.el.querySelectorAll(".Py_answer.clearfix .font14");
  3382. }
  3383. for (var i = 0; i < options.length; i++) {
  3384. if (isMy && options[i].querySelectorAll(".fr.dui").length <= 0) {
  3385. continue;
  3386. }
  3387. var optionEl = options[i].querySelector("i.fl");
  3388. var option = {
  3389. option: utils_1.substrex(optionEl.innerHTML, "第", "空"),
  3390. content: options[i].querySelector(".clearfix").innerText,
  3391. };
  3392. ret.correct.push(option);
  3393. }
  3394. return ret;
  3395. };
  3396. cxFillQuestion.prototype.Fill = function (answer) {
  3397. var _this = this;
  3398. return new Promise(function (resolve) {
  3399. var options = _this.options();
  3400. if (!options.length) {
  3401. options = _this.el.querySelector('.Zy_ulTk').querySelectorAll(".XztiHover1");
  3402. }
  3403. var flag = 0;
  3404. for (var i = 0; i < answer.correct.length; i++) {
  3405. for (var j = 0; j < options.length; j++) {
  3406. if (_this.getOption(options[j]) == answer.correct[i].option) {
  3407. flag++;
  3408. var el = options[j].querySelector("input.inp");
  3409. if (!el) {
  3410. var uedit = _this.context.$(options[j]).find('textarea');
  3411. if (uedit.length <= 0) {
  3412. _this.AddNotice(_this.getOption(options[j]) + "空发生了一个错误");
  3413. continue;
  3414. }
  3415. _this.context.UE.getEditor(uedit.attr('name')).setContent(answer.correct[i].content);
  3416. _this.AddNotice(_this.getOption(options[j]) + ":" + answer.correct[i].content);
  3417. }
  3418. else {
  3419. el.value = utils_1.removeHTMLTag(answer.correct[i].content);
  3420. _this.AddNotice(_this.getOption(options[j]) + ":" + answer.correct[i].content);
  3421. }
  3422. }
  3423. }
  3424. }
  3425. if (flag == options.length) {
  3426. return resolve("ok");
  3427. }
  3428. return resolve("no_match");
  3429. });
  3430. };
  3431. return cxFillQuestion;
  3432. }(cxQuestion));
  3433. //TODO: 优化
  3434. var cxExamSelectQuestion = /** @class */ (function (_super) {
  3435. __extends(cxExamSelectQuestion, _super);
  3436. function cxExamSelectQuestion() {
  3437. return _super !== null && _super.apply(this, arguments) || this;
  3438. }
  3439. cxExamSelectQuestion.prototype.options = function () {
  3440. return this.el.querySelectorAll(".Cy_ulBottom.clearfix.w-buttom li input");
  3441. };
  3442. cxExamSelectQuestion.prototype.getContent = function (el) {
  3443. var textOption = this.el.querySelectorAll(".Cy_ulTop.w-top li div.clearfix a");
  3444. var tmpli = el.parentElement.parentElement;
  3445. var pos = -1;
  3446. do {
  3447. tmpli = tmpli.previousElementSibling;
  3448. pos++;
  3449. } while (tmpli != null);
  3450. return textOption[pos].innerHTML;
  3451. };
  3452. cxExamSelectQuestion.prototype.getOption = function (el) {
  3453. return el.parentElement.innerText;
  3454. };
  3455. cxExamSelectQuestion.prototype.click = function (el, content) {
  3456. el.click();
  3457. this.AddNotice(this.getOption(el) + ":" + content);
  3458. };
  3459. return cxExamSelectQuestion;
  3460. }(cxSelectQuestion));
  3461. var cxExamFillQuestion = /** @class */ (function (_super) {
  3462. __extends(cxExamFillQuestion, _super);
  3463. function cxExamFillQuestion() {
  3464. return _super !== null && _super.apply(this, arguments) || this;
  3465. }
  3466. cxExamFillQuestion.prototype.options = function () {
  3467. return this.el.querySelectorAll(".Cy_ulTk .XztiHover1");
  3468. };
  3469. cxExamFillQuestion.prototype.getOption = function (el) {
  3470. var tmpel = el.querySelector(".fb.font14");
  3471. return utils_1.substrex(tmpel.innerHTML, "第", "空");
  3472. };
  3473. cxExamFillQuestion.prototype.Fill = function (answer) {
  3474. var _this = this;
  3475. return new Promise(function (resolve) {
  3476. var options = _this.options();
  3477. var flag = 0;
  3478. for (var i = 0; i < answer.correct.length; i++) {
  3479. for (var j = 0; j < options.length; j++) {
  3480. if (_this.getOption(options[j]) == answer.correct[i].option) {
  3481. flag++;
  3482. var uedit = window.$(options[j]).find('textarea');
  3483. if (uedit.length <= 0) {
  3484. _this.AddNotice(_this.getOption(options[j]) + "空发生了一个错误");
  3485. continue;
  3486. }
  3487. window.UE.getEditor(uedit.attr('name')).setContent(answer.correct[i].content);
  3488. _this.AddNotice(_this.getOption(options[j]) + ":" + answer.correct[i].content);
  3489. }
  3490. }
  3491. }
  3492. if (flag == options.length) {
  3493. return resolve("ok");
  3494. }
  3495. return resolve("no_match");
  3496. });
  3497. };
  3498. cxExamFillQuestion.prototype.Correct = function () {
  3499. var correct = this.isCorrect();
  3500. if (correct == null) {
  3501. return null;
  3502. }
  3503. var ret = this.defaultAnswer();
  3504. var options = this.el.querySelectorAll(".Py_tk div[id] span.font14");
  3505. var isMy = false;
  3506. if (options.length <= 0) {
  3507. isMy = true;
  3508. options = this.el.querySelectorAll(".Py_answer.clearfix .font14");
  3509. }
  3510. for (var i = 0; i < options.length; i++) {
  3511. if (isMy && options[i].querySelectorAll(".fr.dui").length <= 0) {
  3512. continue;
  3513. }
  3514. var optionEl = options[i].querySelector("i");
  3515. var option = {
  3516. option: utils_1.substrex(optionEl.innerHTML, "第", "空"),
  3517. content: options[i].innerHTML.substr(options[i].innerHTML.indexOf("</i>") + 4),
  3518. };
  3519. ret.correct.push(option);
  3520. }
  3521. return ret;
  3522. };
  3523. return cxExamFillQuestion;
  3524. }(cxFillQuestion));
  3525. var cxExamJudgeQuestion = /** @class */ (function (_super) {
  3526. __extends(cxExamJudgeQuestion, _super);
  3527. function cxExamJudgeQuestion() {
  3528. return _super !== null && _super.apply(this, arguments) || this;
  3529. }
  3530. cxExamJudgeQuestion.prototype.options = function () {
  3531. return this.el.querySelectorAll(".Cy_ulBottom.clearfix li");
  3532. };
  3533. return cxExamJudgeQuestion;
  3534. }(cxJudgeQuestion));
  3535. /***/ }),
  3536. /***/ "./src/mooc/chaoxing/read.ts":
  3537. /*!***********************************!*\
  3538. !*** ./src/mooc/chaoxing/read.ts ***!
  3539. \***********************************/
  3540. /*! no static exports found */
  3541. /***/ (function(module, exports, __webpack_require__) {
  3542. "use strict";
  3543. Object.defineProperty(exports, "__esModule", { value: true });
  3544. exports.Exam = exports.ReadStartPage = exports.Read = void 0;
  3545. var application_1 = __webpack_require__(/*! @App/internal/application */ "./src/internal/application.ts");
  3546. var utils_1 = __webpack_require__(/*! @App/internal/utils/utils */ "./src/internal/utils/utils.ts");
  3547. var question_1 = __webpack_require__(/*! @App/internal/app/question */ "./src/internal/app/question.ts");
  3548. var Read = /** @class */ (function () {
  3549. function Read() {
  3550. }
  3551. Read.prototype.Init = function () {
  3552. var timer;
  3553. var slide = function () {
  3554. if (window.getScrollHeight() - window.getHeight() <= window.getScrollTop() + 40) {
  3555. var next = document.querySelectorAll('.mb15.course_section > a.wh.wh');
  3556. var flag = false;
  3557. for (var i = 0; i < next.length; i++) {
  3558. if (flag) {
  3559. next[i].click();
  3560. return;
  3561. }
  3562. if (document.URL == next[i].href) {
  3563. flag = true;
  3564. }
  3565. }
  3566. application_1.Application.App.log.Warn("阅读完成啦~");
  3567. clearTimeout(timer);
  3568. return;
  3569. }
  3570. window.scrollTo(0, window.getScrollTop() + utils_1.randNumber(60, 80));
  3571. timer = setTimeout(slide, utils_1.randNumber(10, 20) * 500);
  3572. };
  3573. window.addEventListener("load", function () {
  3574. slide();
  3575. });
  3576. };
  3577. return Read;
  3578. }());
  3579. exports.Read = Read;
  3580. var ReadStartPage = /** @class */ (function () {
  3581. function ReadStartPage() {
  3582. }
  3583. ReadStartPage.prototype.Init = function () {
  3584. window.addEventListener("load", function () {
  3585. if (!application_1.Application.App.config.auto) {
  3586. return application_1.Application.App.log.Info("开启自动挂机能够自动阅读文章哦");
  3587. }
  3588. application_1.Application.App.log.Info("请在10秒内选择章节,否则扩展将从第一章自动开始");
  3589. setTimeout(function () {
  3590. var el = document.querySelector(".mb15.course_section.fix");
  3591. el.querySelector("a").click();
  3592. }, 10000);
  3593. });
  3594. };
  3595. return ReadStartPage;
  3596. }());
  3597. exports.ReadStartPage = ReadStartPage;
  3598. var Exam = /** @class */ (function () {
  3599. function Exam() {
  3600. }
  3601. Exam.prototype.Init = function () {
  3602. var bank = new question_1.ToolsQuestionBank("cx");
  3603. window.addEventListener("load", function () {
  3604. var str = application_1.Application.GlobalContext.document.documentElement.innerHTML;
  3605. var m;
  3606. var regex = new RegExp(/goTest\(.*?,(\d+),\d+,.*?,(\d+),false,/g);
  3607. var info = new Array();
  3608. while ((m = regex.exec(str)) !== null) {
  3609. var tmp = { refer: document.URL, id: "exam-" + m[2], info: m[2] };
  3610. info.push(tmp);
  3611. }
  3612. regex = new RegExp(/lookUpPaper\('(\d+)','\d+','(\d+)'/g);
  3613. while ((m = regex.exec(str)) !== null) {
  3614. var tmp = { refer: document.URL, id: "exam-" + m[2], info: m[2] };
  3615. info.push(tmp);
  3616. }
  3617. bank.CheckCourse(info);
  3618. });
  3619. };
  3620. return Exam;
  3621. }());
  3622. exports.Exam = Exam;
  3623. /***/ }),
  3624. /***/ "./src/mooc/chaoxing/special.ts":
  3625. /*!**************************************!*\
  3626. !*** ./src/mooc/chaoxing/special.ts ***!
  3627. \**************************************/
  3628. /*! no static exports found */
  3629. /***/ (function(module, exports, __webpack_require__) {
  3630. "use strict";
  3631. var __extends = (this && this.__extends) || (function () {
  3632. var extendStatics = function (d, b) {
  3633. extendStatics = Object.setPrototypeOf ||
  3634. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3635. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3636. return extendStatics(d, b);
  3637. };
  3638. return function (d, b) {
  3639. extendStatics(d, b);
  3640. function __() { this.constructor = d; }
  3641. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3642. };
  3643. })();
  3644. Object.defineProperty(exports, "__esModule", { value: true });
  3645. exports.CxAudioControlBar = exports.CxAudioTask = exports.CxAudioOptimization = exports.CxDocumentTask = void 0;
  3646. var task_1 = __webpack_require__(/*! @App/mooc/chaoxing/task */ "./src/mooc/chaoxing/task.ts");
  3647. var utils_1 = __webpack_require__(/*! @App/internal/utils/utils */ "./src/internal/utils/utils.ts");
  3648. var application_1 = __webpack_require__(/*! @App/internal/application */ "./src/internal/application.ts");
  3649. var video_1 = __webpack_require__(/*! @App/mooc/chaoxing/video */ "./src/mooc/chaoxing/video.ts");
  3650. var utils_2 = __webpack_require__(/*! @App/mooc/chaoxing/utils */ "./src/mooc/chaoxing/utils.ts");
  3651. var hook_1 = __webpack_require__(/*! @App/internal/utils/hook */ "./src/internal/utils/hook.ts");
  3652. var CxDocumentTask = /** @class */ (function (_super) {
  3653. __extends(CxDocumentTask, _super);
  3654. function CxDocumentTask() {
  3655. return _super !== null && _super.apply(this, arguments) || this;
  3656. }
  3657. CxDocumentTask.prototype.Start = function () {
  3658. var _this = this;
  3659. return new Promise(function (resolve) {
  3660. var next = function () {
  3661. var el = _this.context.document.querySelector(".imglook > .mkeRbtn");
  3662. if (el.style.visibility == "hidden") {
  3663. _this.callEvent("complete");
  3664. return;
  3665. }
  3666. el.click();
  3667. _this.time = _this.context.setTimeout(next, utils_1.randNumber(1, 5) * 1000);
  3668. resolve();
  3669. };
  3670. _this.time = _this.context.setTimeout(next, utils_1.randNumber(1, 5) * 1000);
  3671. });
  3672. };
  3673. CxDocumentTask.prototype.Type = function () {
  3674. return "document";
  3675. };
  3676. return CxDocumentTask;
  3677. }(task_1.CxTask));
  3678. exports.CxDocumentTask = CxDocumentTask;
  3679. var CxAudioOptimization = /** @class */ (function (_super) {
  3680. __extends(CxAudioOptimization, _super);
  3681. function CxAudioOptimization() {
  3682. return _super !== null && _super.apply(this, arguments) || this;
  3683. }
  3684. CxAudioOptimization.prototype.Init = function () {
  3685. var _this = this;
  3686. //对播放器进行优化
  3687. window.addEventListener("load", function () {
  3688. application_1.Application.App.config.super_mode && utils_1.isPhone() && (application_1.Application.GlobalContext.Ext.isChaoxing = true);
  3689. });
  3690. this.hook();
  3691. document.addEventListener("readystatechange", function () {
  3692. _this.hook();
  3693. });
  3694. this.Api();
  3695. };
  3696. CxAudioOptimization.prototype.hook = function () {
  3697. if (document.readyState != "interactive") {
  3698. return;
  3699. }
  3700. application_1.Application.App.log.Debug("hook cx audio");
  3701. var self = this;
  3702. var paramHook = new hook_1.Hook("params2VideoOpt", application_1.Application.GlobalContext.ans.AudioJs.prototype);
  3703. paramHook.Middleware(function (next) {
  3704. var args = [];
  3705. for (var _i = 1; _i < arguments.length; _i++) {
  3706. args[_i - 1] = arguments[_i];
  3707. }
  3708. self.param = args[0];
  3709. return next.apply(this, args);
  3710. });
  3711. application_1.Application.GlobalContext.Ext.isSogou = false;
  3712. };
  3713. return CxAudioOptimization;
  3714. }(video_1.CxVideoOptimization));
  3715. exports.CxAudioOptimization = CxAudioOptimization;
  3716. var CxAudioTask = /** @class */ (function (_super) {
  3717. __extends(CxAudioTask, _super);
  3718. function CxAudioTask() {
  3719. return _super !== null && _super.apply(this, arguments) || this;
  3720. }
  3721. CxAudioTask.prototype.queryVideo = function () {
  3722. return this.context.document.getElementById("audio_html5_api");
  3723. };
  3724. return CxAudioTask;
  3725. }(video_1.Video));
  3726. exports.CxAudioTask = CxAudioTask;
  3727. var CxAudioControlBar = /** @class */ (function (_super) {
  3728. __extends(CxAudioControlBar, _super);
  3729. function CxAudioControlBar() {
  3730. return _super !== null && _super.apply(this, arguments) || this;
  3731. }
  3732. CxAudioControlBar.prototype.defaultBtn = function () {
  3733. var _this = this;
  3734. _super.prototype.defaultBtn.call(this);
  3735. var pass = utils_2.CssBtn(utils_1.createBtn("秒过嘤频", "秒过会被后台检测到", "cx-btn"));
  3736. pass.style.background = "#F57C00";
  3737. pass.onclick = function () {
  3738. if (!utils_1.protocolPrompt("秒过会产生不良记录,是否继续?", "boom_audio_no_prompt")) {
  3739. return;
  3740. }
  3741. _this.task.sendEndTimePack(function (isPassed) {
  3742. if (isPassed) {
  3743. alert('秒过成功,刷新后查看效果');
  3744. }
  3745. else {
  3746. alert('操作失败,错误');
  3747. }
  3748. });
  3749. };
  3750. // this.prev.append(pass, this.download());
  3751. };
  3752. return CxAudioControlBar;
  3753. }(task_1.CxTaskControlBar));
  3754. exports.CxAudioControlBar = CxAudioControlBar;
  3755. /***/ }),
  3756. /***/ "./src/mooc/chaoxing/task.ts":
  3757. /*!***********************************!*\
  3758. !*** ./src/mooc/chaoxing/task.ts ***!
  3759. \***********************************/
  3760. /*! no static exports found */
  3761. /***/ (function(module, exports, __webpack_require__) {
  3762. "use strict";
  3763. var __extends = (this && this.__extends) || (function () {
  3764. var extendStatics = function (d, b) {
  3765. extendStatics = Object.setPrototypeOf ||
  3766. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3767. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3768. return extendStatics(d, b);
  3769. };
  3770. return function (d, b) {
  3771. extendStatics(d, b);
  3772. function __() { this.constructor = d; }
  3773. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3774. };
  3775. })();
  3776. var __spreadArrays = (this && this.__spreadArrays) || function () {
  3777. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  3778. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  3779. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  3780. r[k] = a[j];
  3781. return r;
  3782. };
  3783. Object.defineProperty(exports, "__esModule", { value: true });
  3784. exports.CxTaskControlBar = exports.CxTask = void 0;
  3785. var utils_1 = __webpack_require__(/*! @App/mooc/chaoxing/utils */ "./src/mooc/chaoxing/utils.ts");
  3786. var utils_2 = __webpack_require__(/*! @App/internal/utils/utils */ "./src/internal/utils/utils.ts");
  3787. var application_1 = __webpack_require__(/*! @App/internal/application */ "./src/internal/application.ts");
  3788. var task_1 = __webpack_require__(/*! @App/internal/app/task */ "./src/internal/app/task.ts");
  3789. var CxTask = /** @class */ (function (_super) {
  3790. __extends(CxTask, _super);
  3791. function CxTask(context, taskinfo) {
  3792. var _this = _super.call(this) || this;
  3793. _this.taskinfo = taskinfo;
  3794. _this.context = context;
  3795. if (_this.taskinfo.job) {
  3796. _this.done = false;
  3797. }
  3798. else {
  3799. _this.done = true;
  3800. }
  3801. return _this;
  3802. }
  3803. CxTask.prototype.callEvent = function (event) {
  3804. var args = [];
  3805. for (var _i = 1; _i < arguments.length; _i++) {
  3806. args[_i - 1] = arguments[_i];
  3807. }
  3808. if (event == "complete") {
  3809. this.done = true;
  3810. }
  3811. _super.prototype.callEvent.apply(this, __spreadArrays([event], args));
  3812. };
  3813. CxTask.prototype.Init = function () {
  3814. return new Promise(function (resolve) {
  3815. resolve();
  3816. });
  3817. };
  3818. CxTask.prototype.Submit = function () {
  3819. return new Promise(function (resolve) {
  3820. resolve();
  3821. });
  3822. };
  3823. //TODO:停止
  3824. CxTask.prototype.Stop = function () {
  3825. return new Promise(function (resolve) {
  3826. resolve();
  3827. });
  3828. };
  3829. CxTask.prototype.Done = function () {
  3830. return this.done;
  3831. };
  3832. return CxTask;
  3833. }(task_1.Task));
  3834. exports.CxTask = CxTask;
  3835. var CxTaskControlBar = /** @class */ (function () {
  3836. function CxTaskControlBar(prev, task) {
  3837. this.task = task;
  3838. this.prev = document.createElement("div");
  3839. prev.style.textAlign = "center";
  3840. prev.style.width = "100%";
  3841. prev.prepend(this.prev);
  3842. this.defaultBtn();
  3843. }
  3844. CxTaskControlBar.prototype.defaultBtn = function () {
  3845. var _this = this;
  3846. var startBtn = utils_1.CssBtn(utils_2.createBtn(application_1.Application.App.config.auto ? "暂停挂机" : "开始挂机", "点击开始自动挂机", "cx-btn"));
  3847. startBtn.onclick = function () {
  3848. if (startBtn.innerText == '暂停挂机') {
  3849. application_1.Application.App.config.auto = false;
  3850. startBtn.innerText = "开始挂机";
  3851. startBtn.title = "点击开始自动挂机";
  3852. application_1.Application.App.log.Info("挂机停止了");
  3853. }
  3854. else {
  3855. application_1.Application.App.config.auto = true;
  3856. startBtn.innerText = '暂停挂机';
  3857. startBtn.title = "停止挂机,开始好好学习";
  3858. application_1.Application.App.log.Info("挂机开始了");
  3859. _this.task.Start();
  3860. }
  3861. };
  3862. this.prev.append(startBtn);
  3863. };
  3864. CxTaskControlBar.prototype.append = function (el) {
  3865. this.prev.append(el);
  3866. };
  3867. return CxTaskControlBar;
  3868. }());
  3869. exports.CxTaskControlBar = CxTaskControlBar;
  3870. /***/ }),
  3871. /***/ "./src/mooc/chaoxing/topic.ts":
  3872. /*!************************************!*\
  3873. !*** ./src/mooc/chaoxing/topic.ts ***!
  3874. \************************************/
  3875. /*! no static exports found */
  3876. /***/ (function(module, exports, __webpack_require__) {
  3877. "use strict";
  3878. var __extends = (this && this.__extends) || (function () {
  3879. var extendStatics = function (d, b) {
  3880. extendStatics = Object.setPrototypeOf ||
  3881. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3882. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3883. return extendStatics(d, b);
  3884. };
  3885. return function (d, b) {
  3886. extendStatics(d, b);
  3887. function __() { this.constructor = d; }
  3888. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3889. };
  3890. })();
  3891. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  3892. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  3893. return new (P || (P = Promise))(function (resolve, reject) {
  3894. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  3895. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  3896. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  3897. step((generator = generator.apply(thisArg, _arguments || [])).next());
  3898. });
  3899. };
  3900. var __generator = (this && this.__generator) || function (thisArg, body) {
  3901. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  3902. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  3903. function verb(n) { return function (v) { return step([n, v]); }; }
  3904. function step(op) {
  3905. if (f) throw new TypeError("Generator is already executing.");
  3906. while (_) try {
  3907. 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;
  3908. if (y = 0, t) op = [op[0] & 2, t.value];
  3909. switch (op[0]) {
  3910. case 0: case 1: t = op; break;
  3911. case 4: _.label++; return { value: op[1], done: false };
  3912. case 5: _.label++; y = op[1]; op = [0]; continue;
  3913. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  3914. default:
  3915. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  3916. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  3917. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  3918. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  3919. if (t[2]) _.ops.pop();
  3920. _.trys.pop(); continue;
  3921. }
  3922. op = body.call(thisArg, _);
  3923. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  3924. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  3925. }
  3926. };
  3927. Object.defineProperty(exports, "__esModule", { value: true });
  3928. exports.HomeworkTopic = exports.ExamTopic = exports.CxCourseTopic = exports.CxCourseQueryQuestion = exports.TopicAdapter = exports.CxTopicControlBar = void 0;
  3929. var utils_1 = __webpack_require__(/*! ./utils */ "./src/mooc/chaoxing/utils.ts");
  3930. var utils_2 = __webpack_require__(/*! @App/internal/utils/utils */ "./src/internal/utils/utils.ts");
  3931. var application_1 = __webpack_require__(/*! @App/internal/application */ "./src/internal/application.ts");
  3932. var question_1 = __webpack_require__(/*! @App/internal/app/question */ "./src/internal/app/question.ts");
  3933. var question_2 = __webpack_require__(/*! ./question */ "./src/mooc/chaoxing/question.ts");
  3934. var topic_1 = __webpack_require__(/*! @App/internal/app/topic */ "./src/internal/app/topic.ts");
  3935. var task_1 = __webpack_require__(/*! @App/mooc/chaoxing/task */ "./src/mooc/chaoxing/task.ts");
  3936. var CxTopicControlBar = /** @class */ (function (_super) {
  3937. __extends(CxTopicControlBar, _super);
  3938. function CxTopicControlBar() {
  3939. return _super !== null && _super.apply(this, arguments) || this;
  3940. }
  3941. CxTopicControlBar.prototype.defaultBtn = function () {
  3942. var _this = this;
  3943. _super.prototype.defaultBtn.call(this);
  3944. var topic = utils_1.CssBtn(utils_2.createBtn("使用棚子AIGC", "手动填完答案,再开启挂机", "cx-btn"));
  3945. topic.style.background = "#3fae93";
  3946. this.prev.append(topic);
  3947. // 绑定事件
  3948. topic.onclick = function () { return __awaiter(_this, void 0, void 0, function () {
  3949. return __generator(this, function (_a) {
  3950. topic.innerText = "答案搜索中111...";
  3951. this.task.Start().then(function (ret) {
  3952. ret = ret || "搜索题目111";
  3953. topic.innerText = question_1.QuestionStatusString(ret);
  3954. });
  3955. return [2 /*return*/];
  3956. });
  3957. }); };
  3958. };
  3959. return CxTopicControlBar;
  3960. }(task_1.CxTaskControlBar));
  3961. exports.CxTopicControlBar = CxTopicControlBar;
  3962. var TopicAdapter = /** @class */ (function (_super) {
  3963. __extends(TopicAdapter, _super);
  3964. function TopicAdapter(context, taskinfo, topic) {
  3965. var _this = _super.call(this, context, taskinfo) || this;
  3966. _this.topic = topic;
  3967. return _this;
  3968. }
  3969. TopicAdapter.prototype.Init = function () {
  3970. var _this = this;
  3971. return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
  3972. return __generator(this, function (_a) {
  3973. switch (_a.label) {
  3974. case 0:
  3975. application_1.Application.App.log.Debug("题目信息", this.taskinfo);
  3976. return [4 /*yield*/, this.topic.Init()];
  3977. case 1:
  3978. _a.sent();
  3979. resolve(undefined);
  3980. return [2 /*return*/];
  3981. }
  3982. });
  3983. }); });
  3984. };
  3985. TopicAdapter.prototype.Start = function () {
  3986. var _this = this;
  3987. return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
  3988. var ret;
  3989. return __generator(this, function (_a) {
  3990. switch (_a.label) {
  3991. case 0:
  3992. if (this.lock) {
  3993. return [2 /*return*/, resolve("processing")];
  3994. }
  3995. this.lock = true;
  3996. return [4 /*yield*/, this.topic.QueryAnswer()];
  3997. case 1:
  3998. ret = _a.sent();
  3999. this.status = ret;
  4000. this.callEvent("complete");
  4001. this.lock = false;
  4002. return [2 /*return*/, resolve(ret)];
  4003. }
  4004. });
  4005. }); });
  4006. };
  4007. TopicAdapter.prototype.Type = function () {
  4008. return "topic";
  4009. };
  4010. TopicAdapter.prototype.Submit = function () {
  4011. return __awaiter(this, void 0, void 0, function () {
  4012. var _this = this;
  4013. return __generator(this, function (_a) {
  4014. return [2 /*return*/, new Promise(function (resolve) {
  4015. if (_this.status == "success") {
  4016. _this.topic.Submit().then(function () {
  4017. resolve();
  4018. });
  4019. }
  4020. else {
  4021. resolve();
  4022. }
  4023. })];
  4024. });
  4025. });
  4026. };
  4027. return TopicAdapter;
  4028. }(task_1.CxTask));
  4029. exports.TopicAdapter = TopicAdapter;
  4030. var CxCourseQueryQuestion = /** @class */ (function () {
  4031. function CxCourseQueryQuestion(content, createQuestion) {
  4032. this.context = content;
  4033. this.createQuestion = createQuestion;
  4034. }
  4035. CxCourseQueryQuestion.prototype.QueryQuestions = function () {
  4036. var _this = this;
  4037. var timu = this.context.document.querySelectorAll(".TiMu");
  4038. var ret = new Array();
  4039. timu.forEach(function (val) {
  4040. var question = _this.createQuestion(_this.context, val);
  4041. if (question == null) {
  4042. return;
  4043. }
  4044. ret.push(question);
  4045. });
  4046. return ret;
  4047. };
  4048. return CxCourseQueryQuestion;
  4049. }());
  4050. exports.CxCourseQueryQuestion = CxCourseQueryQuestion;
  4051. var CxCourseTopic = /** @class */ (function (_super) {
  4052. __extends(CxCourseTopic, _super);
  4053. function CxCourseTopic(content, answer) {
  4054. var _this = _super.call(this, content, answer) || this;
  4055. answer.CheckCourse();
  4056. return _this;
  4057. }
  4058. CxCourseTopic.prototype.Init = function () {
  4059. var _this = this;
  4060. return new Promise(function (resolve) {
  4061. var timer = _this.context.setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
  4062. return __generator(this, function (_a) {
  4063. switch (_a.label) {
  4064. case 0:
  4065. if (!(this.context.document.readyState == "complete")) return [3 /*break*/, 3];
  4066. this.context.clearInterval(timer);
  4067. if (!(this.context.document.URL.indexOf("selectWorkQuestionYiPiYue") > 0)) return [3 /*break*/, 2];
  4068. return [4 /*yield*/, this.CollectAnswer()];
  4069. case 1:
  4070. _a.sent();
  4071. _a.label = 2;
  4072. case 2:
  4073. resolve(undefined);
  4074. _a.label = 3;
  4075. case 3: return [2 /*return*/];
  4076. }
  4077. });
  4078. }); }, 500);
  4079. });
  4080. };
  4081. CxCourseTopic.prototype.QueryAnswer = function () {
  4082. if (this.context.document.URL.indexOf("selectWorkQuestionYiPiYue") > 0) {
  4083. return null;
  4084. }
  4085. return _super.prototype.QueryAnswer.call(this);
  4086. };
  4087. CxCourseTopic.prototype.Submit = function () {
  4088. var _this = this;
  4089. return new Promise(function (resolve) {
  4090. application_1.Application.App.log.Info("准备提交答案");
  4091. var self = _this;
  4092. _this.context.setTimeout(function () {
  4093. var submit = _this.context.document.querySelector(".Btn_blue_1");
  4094. submit.click();
  4095. _this.context.setTimeout(function () {
  4096. var prompt = _this.context.document.querySelector("#tipContent").innerHTML;
  4097. if (prompt.indexOf("未做完") > 0) {
  4098. alert("提示:" + prompt);
  4099. resolve("未做完");
  4100. application_1.Application.App.log.Fatal("有题目未完成,请手动操作.提示:" + prompt);
  4101. return;
  4102. }
  4103. var timer = _this.context.setInterval(function () {
  4104. prompt = document.getElementById("validate");
  4105. if (prompt.style.display != 'none') {
  4106. //等待验证码接管
  4107. return;
  4108. }
  4109. _this.context.clearInterval(timer);
  4110. _this.context.parent.document.querySelector("#frame_content")
  4111. .addEventListener("load", function () {
  4112. return __awaiter(this, void 0, void 0, function () {
  4113. return __generator(this, function (_a) {
  4114. switch (_a.label) {
  4115. case 0:
  4116. if (!(this.contentWindow.document.URL.indexOf('selectWorkQuestionYiPiYue') > 0)) return [3 /*break*/, 2];
  4117. return [4 /*yield*/, self.CollectAnswer()];
  4118. case 1:
  4119. _a.sent();
  4120. resolve(undefined);
  4121. _a.label = 2;
  4122. case 2: return [2 /*return*/];
  4123. }
  4124. });
  4125. });
  4126. });
  4127. //确定提交
  4128. var submit = _this.context.document.querySelector(".bluebtn");
  4129. submit.click();
  4130. }, 2000);
  4131. }, 2000);
  4132. }, 2000);
  4133. });
  4134. };
  4135. return CxCourseTopic;
  4136. }(topic_1.Topic));
  4137. exports.CxCourseTopic = CxCourseTopic;
  4138. var ExamTopic = /** @class */ (function (_super) {
  4139. __extends(ExamTopic, _super);
  4140. function ExamTopic() {
  4141. return _super !== null && _super.apply(this, arguments) || this;
  4142. }
  4143. ExamTopic.prototype.QueryQuestions = function () {
  4144. var current = document.querySelector(".current");
  4145. var topicType = question_1.SwitchTopicType(current.parentElement.previousElementSibling.innerText);
  4146. var question = question_2.CxQuestionFactory.CreateExamQuestion(window, topicType, document.querySelector(".leftContent.TiMu"));
  4147. var ret = new Array();
  4148. if (question == null) {
  4149. return ret;
  4150. }
  4151. ret.push(question);
  4152. return ret;
  4153. };
  4154. ExamTopic.prototype.Init = function () {
  4155. if (document.URL.indexOf("exam/test/reVersionPaperMarkContentNew") > 0) {
  4156. this.CollectAnswer();
  4157. }
  4158. return null;
  4159. };
  4160. ExamTopic.prototype.Submit = function () {
  4161. return new Promise(function (resolve) {
  4162. resolve(undefined);
  4163. });
  4164. };
  4165. return ExamTopic;
  4166. }(topic_1.Topic));
  4167. exports.ExamTopic = ExamTopic;
  4168. var HomeworkTopic = /** @class */ (function (_super) {
  4169. __extends(HomeworkTopic, _super);
  4170. function HomeworkTopic(content, answer) {
  4171. return _super.call(this, content, answer) || this;
  4172. }
  4173. HomeworkTopic.prototype.Init = function () {
  4174. var _this = this;
  4175. return new Promise(function (resolve) {
  4176. if (!document.querySelector("input#workRelationId")) {
  4177. _this.CollectAnswer();
  4178. }
  4179. resolve();
  4180. });
  4181. };
  4182. HomeworkTopic.prototype.Submit = function () {
  4183. return new Promise(function (resolve) {
  4184. resolve();
  4185. });
  4186. };
  4187. return HomeworkTopic;
  4188. }(CxCourseTopic));
  4189. exports.HomeworkTopic = HomeworkTopic;
  4190. /***/ }),
  4191. /***/ "./src/mooc/chaoxing/utils.ts":
  4192. /*!************************************!*\
  4193. !*** ./src/mooc/chaoxing/utils.ts ***!
  4194. \************************************/
  4195. /*! no static exports found */
  4196. /***/ (function(module, exports, __webpack_require__) {
  4197. "use strict";
  4198. Object.defineProperty(exports, "__esModule", { value: true });
  4199. exports.CreateNoteLine = exports.CssBtn = void 0;
  4200. /**
  4201. * 美化按钮
  4202. */
  4203. function CssBtn(btn) {
  4204. btn.style.outline = 'none';
  4205. btn.style.border = '0';
  4206. btn.style.background = '#7d9d35';
  4207. btn.style.color = '#fff';
  4208. btn.style.borderRadius = '4px';
  4209. btn.style.padding = '2px 8px';
  4210. btn.style.cursor = 'pointer';
  4211. btn.style.fontSize = '12px';
  4212. btn.style.marginLeft = '4px';
  4213. btn.onmousemove = function () {
  4214. btn.style.boxShadow = '1px 1px 1px 1px #ccc';
  4215. };
  4216. btn.onmouseout = function () {
  4217. btn.style.boxShadow = '';
  4218. };
  4219. return btn;
  4220. }
  4221. exports.CssBtn = CssBtn;
  4222. function CreateNoteLine(text, label, append, after) {
  4223. var p = document.createElement("p");
  4224. p.style.color = "red";
  4225. p.style.fontSize = "14px";
  4226. p.className = "prompt-line-" + label;
  4227. p.innerHTML = text;
  4228. if (append != undefined) {
  4229. append.append(p);
  4230. }
  4231. if (after != undefined) {
  4232. after.after(p);
  4233. }
  4234. return p;
  4235. }
  4236. exports.CreateNoteLine = CreateNoteLine;
  4237. /***/ }),
  4238. /***/ "./src/mooc/chaoxing/vcode.ts":
  4239. /*!************************************!*\
  4240. !*** ./src/mooc/chaoxing/vcode.ts ***!
  4241. \************************************/
  4242. /*! no static exports found */
  4243. /***/ (function(module, exports, __webpack_require__) {
  4244. "use strict";
  4245. Object.defineProperty(exports, "__esModule", { value: true });
  4246. exports.CxCourseVCode = void 0;
  4247. var utils_1 = __webpack_require__(/*! ./utils */ "./src/mooc/chaoxing/utils.ts");
  4248. var CxCourseVCode = /** @class */ (function () {
  4249. function CxCourseVCode() {
  4250. }
  4251. CxCourseVCode.prototype.Listen = function (callback) {
  4252. var imgel;
  4253. window.addEventListener("load", function () {
  4254. if (imgel = document.getElementById("imgVerCode")) {
  4255. imgel.addEventListener("load", function () {
  4256. if (imgel.getAttribute("src").indexOf('?') < 0) {
  4257. return;
  4258. }
  4259. var parent = document.querySelector('#sub').parentElement.parentElement;
  4260. var old = parent.querySelector(".prompt-line-dama");
  4261. if (old) {
  4262. old.remove();
  4263. }
  4264. var notice = utils_1.CreateNoteLine('cxmooc自动打码中...', 'dama', parent);
  4265. callback(new CxCourseFillVCode(imgel, notice));
  4266. });
  4267. }
  4268. });
  4269. };
  4270. return CxCourseVCode;
  4271. }());
  4272. exports.CxCourseVCode = CxCourseVCode;
  4273. var CxCourseFillVCode = /** @class */ (function () {
  4274. function CxCourseFillVCode(img, notice) {
  4275. this.img = img;
  4276. this.notice = notice;
  4277. }
  4278. CxCourseFillVCode.prototype.GetImage = function () {
  4279. return this.img;
  4280. };
  4281. CxCourseFillVCode.prototype.Fill = function (status, msg, code) {
  4282. switch (status) {
  4283. case "ok": {
  4284. this.notice.innerText = "cxmooc打码成功,准备提交";
  4285. document.querySelector('input#code').value = code;
  4286. setTimeout(function () {
  4287. document.querySelector('a#sub').click();
  4288. }, 3000);
  4289. break;
  4290. }
  4291. default: {
  4292. alert(msg);
  4293. this.notice.innerText = msg;
  4294. }
  4295. }
  4296. };
  4297. return CxCourseFillVCode;
  4298. }());
  4299. /***/ }),
  4300. /***/ "./src/mooc/chaoxing/video.ts":
  4301. /*!************************************!*\
  4302. !*** ./src/mooc/chaoxing/video.ts ***!
  4303. \************************************/
  4304. /*! no static exports found */
  4305. /***/ (function(module, exports, __webpack_require__) {
  4306. "use strict";
  4307. var __extends = (this && this.__extends) || (function () {
  4308. var extendStatics = function (d, b) {
  4309. extendStatics = Object.setPrototypeOf ||
  4310. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4311. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4312. return extendStatics(d, b);
  4313. };
  4314. return function (d, b) {
  4315. extendStatics(d, b);
  4316. function __() { this.constructor = d; }
  4317. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4318. };
  4319. })();
  4320. Object.defineProperty(exports, "__esModule", { value: true });
  4321. exports.Video = exports.CxVideoControlBar = exports.CxVideoOptimization = void 0;
  4322. var hook_1 = __webpack_require__(/*! @App/internal/utils/hook */ "./src/internal/utils/hook.ts");
  4323. var application_1 = __webpack_require__(/*! @App/internal/application */ "./src/internal/application.ts");
  4324. var utils_1 = __webpack_require__(/*! @App/internal/utils/utils */ "./src/internal/utils/utils.ts");
  4325. var utils_2 = __webpack_require__(/*! ./utils */ "./src/mooc/chaoxing/utils.ts");
  4326. var task_1 = __webpack_require__(/*! @App/mooc/chaoxing/task */ "./src/mooc/chaoxing/task.ts");
  4327. // 优化播放器
  4328. var CxVideoOptimization = /** @class */ (function () {
  4329. function CxVideoOptimization() {
  4330. }
  4331. CxVideoOptimization.prototype.Init = function () {
  4332. var _this = this;
  4333. //对播放器进行优化
  4334. window.addEventListener("load", function () {
  4335. application_1.Application.App.config.super_mode && utils_1.isPhone() && (application_1.Application.GlobalContext.Ext.isChaoxing = true);
  4336. });
  4337. this.hook();
  4338. document.addEventListener("readystatechange", function () {
  4339. _this.hook();
  4340. });
  4341. this.Api();
  4342. };
  4343. CxVideoOptimization.prototype.hook = function () {
  4344. if (document.readyState != "interactive") {
  4345. return;
  4346. }
  4347. application_1.Application.App.log.Debug("hook cx video");
  4348. var dataHook = new hook_1.Hook("decode", application_1.Application.GlobalContext.Ext);
  4349. var self = this;
  4350. dataHook.Middleware(function (next) {
  4351. var args = [];
  4352. for (var _i = 1; _i < arguments.length; _i++) {
  4353. args[_i - 1] = arguments[_i];
  4354. }
  4355. var ret = next.apply(this, args);
  4356. if (application_1.Application.App.config.super_mode && ret.danmaku == 1) {
  4357. ret.danmaku = 0;
  4358. }
  4359. return ret;
  4360. });
  4361. window.frameElement.setAttribute("fastforward", "");
  4362. window.frameElement.setAttribute("switchwindow", "");
  4363. var paramHook = new hook_1.Hook("params2VideoOpt", application_1.Application.GlobalContext.ans.VideoJs.prototype);
  4364. paramHook.Middleware(function (next) {
  4365. var args = [];
  4366. for (var _i = 1; _i < arguments.length; _i++) {
  4367. args[_i - 1] = arguments[_i];
  4368. }
  4369. self.param = args[0];
  4370. var ret = next.apply(this, args);
  4371. ret.plugins.timelineObjects.url = self.param.rootPath + "/richvideo/initdatawithviewer";
  4372. var cdn = application_1.Application.App.config.video_cdn || localStorage["cdn"] || "公网1";
  4373. for (var i = 0; i < ret.playlines.length; i++) {
  4374. if (ret.playlines[i].label == cdn) {
  4375. var copy = ret.playlines[i];
  4376. ret.playlines.splice(i, 1);
  4377. ret.playlines.splice(0, 0, copy);
  4378. }
  4379. }
  4380. localStorage["cdn"] = ret.playlines[0].label;
  4381. delete ret.plugins.studyControl;
  4382. return ret;
  4383. });
  4384. application_1.Application.GlobalContext.Ext.isSogou = false;
  4385. var errorHook = new hook_1.Hook("afterRender", application_1.Application.GlobalContext.ans.videojs.ErrorDisplay.prototype);
  4386. errorHook.Middleware(function (next) {
  4387. var _this = this;
  4388. var args = [];
  4389. for (var _i = 1; _i < arguments.length; _i++) {
  4390. args[_i - 1] = arguments[_i];
  4391. }
  4392. var ret = next.apply(this, args);
  4393. setTimeout(function () {
  4394. var nowCdn = _this.renderData.selectedIndex;
  4395. var playlines = _this.renderData.playlines;
  4396. var cdn = application_1.Application.App.config.video_cdn || localStorage["cdn"] || "公网1";
  4397. for (var i = 0; i < playlines.length; i++) {
  4398. if (i != nowCdn) {
  4399. if (cdn == "") {
  4400. localStorage["cdn"] = playlines[i].label;
  4401. return _this.onSelected(i);
  4402. }
  4403. else if (cdn == playlines[i].label) {
  4404. localStorage["cdn"] = playlines[i].label;
  4405. return _this.onSelected(i);
  4406. }
  4407. }
  4408. }
  4409. var index = (nowCdn + 1) % playlines.length;
  4410. localStorage["cdn"] = playlines[index].label;
  4411. return _this.onSelected(index);
  4412. }, 2000);
  4413. return ret;
  4414. });
  4415. };
  4416. /**
  4417. * 操作方法
  4418. */
  4419. CxVideoOptimization.prototype.Api = function () {
  4420. var _this = this;
  4421. application_1.Application.GlobalContext.sendTimePack = function (time, callback) {
  4422. if (time == NaN || time == undefined) {
  4423. time = parseInt(_this.param.duration);
  4424. }
  4425. var playTime = Math.round(time || (_this.param.duration - utils_1.randNumber(1, 2)));
  4426. var enc = '[' + _this.param.clazzId + '][' + _this.param.userid + '][' +
  4427. _this.param.jobid + '][' + _this.param.objectId + '][' +
  4428. (playTime * 1000).toString() + '][d_yHJ!$pdA~5][' + (_this.param.duration * 1000).toString() + '][0_' +
  4429. _this.param.duration + ']';
  4430. enc = application_1.Application.GlobalContext.md5(enc);
  4431. utils_1.get(_this.param.reportUrl + '/' + _this.param.dtoken + '?clipTime=0_' + _this.param.duration +
  4432. '&otherInfo=' + _this.param.otherInfo +
  4433. '&userid=' + _this.param.userid + '&rt=0.9&jobid=' + _this.param.jobid +
  4434. '&duration=' + _this.param.duration + '&dtype=Video&objectId=' + _this.param.objectId +
  4435. '&clazzId=' + _this.param.clazzId +
  4436. '&view=pc&playingTime=' + playTime + '&isdrag=4&enc=' + enc, function (data) {
  4437. var isPassed = JSON.parse(data);
  4438. callback(isPassed.isPassed);
  4439. });
  4440. };
  4441. };
  4442. return CxVideoOptimization;
  4443. }());
  4444. exports.CxVideoOptimization = CxVideoOptimization;
  4445. var CxVideoControlBar = /** @class */ (function (_super) {
  4446. __extends(CxVideoControlBar, _super);
  4447. function CxVideoControlBar() {
  4448. return _super !== null && _super.apply(this, arguments) || this;
  4449. }
  4450. CxVideoControlBar.prototype.defaultBtn = function () {
  4451. var _this = this;
  4452. _super.prototype.defaultBtn.call(this);
  4453. var pass = utils_2.CssBtn(utils_1.createBtn("秒过视频", "秒过视频会被后台检测到", "cx-btn"));
  4454. var downloadSubtitle = utils_2.CssBtn(utils_1.createBtn("下载字幕", "我要下载字幕一同食用"));
  4455. pass.style.background = "#F57C00";
  4456. downloadSubtitle.style.background = "#638EE1";
  4457. // this.prev.append(pass, this.download(), downloadSubtitle);
  4458. pass.onclick = function () {
  4459. if (!utils_1.protocolPrompt("秒过视频会产生不良记录,是否继续?", "boom_no_prompt")) {
  4460. return;
  4461. }
  4462. _this.task.sendEndTimePack(function (isPassed) {
  4463. if (isPassed) {
  4464. alert('秒过成功,刷新后查看效果');
  4465. }
  4466. else {
  4467. alert('操作失败,错误');
  4468. }
  4469. });
  4470. };
  4471. downloadSubtitle.onclick = function () {
  4472. _this.task.downloadSubtitle();
  4473. };
  4474. };
  4475. return CxVideoControlBar;
  4476. }(task_1.CxTaskControlBar));
  4477. exports.CxVideoControlBar = CxVideoControlBar;
  4478. var Video = /** @class */ (function (_super) {
  4479. __extends(Video, _super);
  4480. function Video() {
  4481. return _super !== null && _super.apply(this, arguments) || this;
  4482. }
  4483. Video.prototype.queryVideo = function () {
  4484. return this.context.document.getElementById("video_html5_api");
  4485. };
  4486. Video.prototype.Init = function () {
  4487. var _this = this;
  4488. return new Promise(function (resolve) {
  4489. application_1.Application.App.log.Debug("播放器配置", _this.taskinfo);
  4490. var timer = _this.context.setInterval(function () {
  4491. try {
  4492. var video = _this.queryVideo();
  4493. if (video == undefined) {
  4494. if (_this.context.document.querySelector("#reader").innerHTML.indexOf("您没有安装flashplayer") >= 0) {
  4495. _this.context.clearInterval(timer);
  4496. _this.flash = true;
  4497. resolve(undefined);
  4498. }
  4499. return;
  4500. }
  4501. _this.context.clearInterval(timer);
  4502. _this.video = video;
  4503. _this.initPlayer();
  4504. _this.video.addEventListener("ended", function () {
  4505. _this.end = true;
  4506. _this.context.clearInterval(_this.time);
  4507. _this.callEvent("complete");
  4508. });
  4509. resolve(undefined);
  4510. }
  4511. catch (error) {
  4512. application_1.Application.App.log.Debug("初始化video错误", error);
  4513. }
  4514. }, 500);
  4515. });
  4516. };
  4517. Video.prototype.Type = function () {
  4518. return "video";
  4519. };
  4520. Video.prototype.Start = function () {
  4521. var _this = this;
  4522. return new Promise(function (resolve) {
  4523. application_1.Application.App.log.Debug("开始播放视频");
  4524. if (_this.flash) {
  4525. resolve(undefined);
  4526. return _this.callEvent("complete");
  4527. }
  4528. //定时运行
  4529. _this.time = _this.context.setInterval(function () {
  4530. application_1.Application.App.config.auto && _this.video.paused && _this.video.play();
  4531. }, 5000);
  4532. //同时运行多视频的兼容,后续看看能不能hook
  4533. _this.video.addEventListener("pause", function () {
  4534. if (_this.video.currentTime <= _this.video.duration - 5) {
  4535. if (!_this.end) {
  4536. _this.video.play();
  4537. }
  4538. }
  4539. });
  4540. _this.video.play();
  4541. resolve(undefined);
  4542. });
  4543. };
  4544. Video.prototype.initPlayer = function () {
  4545. this.playbackRate = this._playbackRate;
  4546. this.muted = this._muted;
  4547. };
  4548. /**
  4549. * 秒过
  4550. */
  4551. Video.prototype.sendEndTimePack = function (callback) {
  4552. this.sendTimePack(this.video.duration, callback);
  4553. };
  4554. Video.prototype.sendTimePack = function (time, callback) {
  4555. this.context.sendTimePack(time, function (isPassed) {
  4556. callback(isPassed);
  4557. });
  4558. };
  4559. Video.prototype.downloadSubtitle = function () {
  4560. utils_1.get('/richvideo/subtitle?mid=' + this.taskinfo.property.mid + '&_dc=' +
  4561. Date.parse(new Date().toString()), function (data) {
  4562. var json = JSON.parse(data);
  4563. if (json.length <= 0) {
  4564. alert("没有字幕!");
  4565. }
  4566. else {
  4567. for (var i = 0; i < json.length; i++) {
  4568. var subtitleURL = json[i]['url'];
  4569. window.open(subtitleURL);
  4570. }
  4571. }
  4572. });
  4573. };
  4574. Object.defineProperty(Video.prototype, "playbackRate", {
  4575. /**
  4576. * 设置播放速度
  4577. */
  4578. set: function (speed) {
  4579. this._playbackRate = speed;
  4580. if (this.video) {
  4581. this.video.playbackRate = speed;
  4582. }
  4583. },
  4584. enumerable: false,
  4585. configurable: true
  4586. });
  4587. Object.defineProperty(Video.prototype, "muted", {
  4588. /**
  4589. * 设置播放静音
  4590. */
  4591. set: function (muted) {
  4592. this._muted = muted;
  4593. if (this.video) {
  4594. this.video.muted = muted;
  4595. }
  4596. },
  4597. enumerable: false,
  4598. configurable: true
  4599. });
  4600. return Video;
  4601. }(task_1.CxTask));
  4602. exports.Video = Video;
  4603. /***/ }),
  4604. /***/ "./src/mooc/mooc.ts":
  4605. /*!**************************!*\
  4606. !*** ./src/mooc/mooc.ts ***!
  4607. \**************************/
  4608. /*! no static exports found */
  4609. /***/ (function(module, exports, __webpack_require__) {
  4610. "use strict";
  4611. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  4612. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  4613. return new (P || (P = Promise))(function (resolve, reject) {
  4614. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  4615. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  4616. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  4617. step((generator = generator.apply(thisArg, _arguments || [])).next());
  4618. });
  4619. };
  4620. var __generator = (this && this.__generator) || function (thisArg, body) {
  4621. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  4622. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  4623. function verb(n) { return function (v) { return step([n, v]); }; }
  4624. function step(op) {
  4625. if (f) throw new TypeError("Generator is already executing.");
  4626. while (_) try {
  4627. 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;
  4628. if (y = 0, t) op = [op[0] & 2, t.value];
  4629. switch (op[0]) {
  4630. case 0: case 1: t = op; break;
  4631. case 4: _.label++; return { value: op[1], done: false };
  4632. case 5: _.label++; y = op[1]; op = [0]; continue;
  4633. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  4634. default:
  4635. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  4636. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  4637. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  4638. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  4639. if (t[2]) _.ops.pop();
  4640. _.trys.pop(); continue;
  4641. }
  4642. op = body.call(thisArg, _);
  4643. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  4644. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  4645. }
  4646. };
  4647. Object.defineProperty(exports, "__esModule", { value: true });
  4648. exports.mooc = void 0;
  4649. var application_1 = __webpack_require__(/*! @App/internal/application */ "./src/internal/application.ts");
  4650. var mooc = /** @class */ (function () {
  4651. function mooc(moocFactory) {
  4652. // 防止taskComplete和reload冲突
  4653. this.once = false;
  4654. this.moocFactory = moocFactory;
  4655. }
  4656. mooc.prototype.start = function () {
  4657. return __awaiter(this, void 0, void 0, function () {
  4658. var state, mooc_1, e_1, isShow_1;
  4659. return __generator(this, function (_a) {
  4660. switch (_a.label) {
  4661. case 0:
  4662. _a.trys.push([0, 3, , 4]);
  4663. state = document.readyState;
  4664. application_1.Application.App.log.Debug("Start document state:", state);
  4665. mooc_1 = this.moocFactory.CreateMooc();
  4666. if (!(mooc_1 != null)) return [3 /*break*/, 2];
  4667. return [4 /*yield*/, mooc_1.Init()];
  4668. case 1:
  4669. _a.sent();
  4670. // MoocTaskSet接口判断,接管流程
  4671. if (mooc_1.Next != undefined) {
  4672. this.runMoocTask(mooc_1);
  4673. }
  4674. _a.label = 2;
  4675. case 2: return [3 /*break*/, 4];
  4676. case 3:
  4677. e_1 = _a.sent();
  4678. application_1.Application.App.log.Fatal("扩展发生了一个致命错误:", e_1);
  4679. return [3 /*break*/, 4];
  4680. case 4:
  4681. //最小化警告
  4682. if (top == self) {
  4683. isShow_1 = false;
  4684. document.addEventListener("visibilitychange", function () {
  4685. if (document.hidden) {
  4686. if (isShow_1) {
  4687. return;
  4688. }
  4689. application_1.Application.App.log.Warn("第一次使用会跳转到'脚本正在试图访问跨域资源;' 点击永久允许即可");
  4690. application_1.Application.App.log.Warn("请注意!最小化可能导致视频无法正常播放!允许切换窗口.");
  4691. application_1.Application.App.log.Warn("由于很多朋友开了倍数导致,时长被清,建议大家开2倍即可");
  4692. isShow_1 = true;
  4693. }
  4694. });
  4695. }
  4696. return [2 /*return*/];
  4697. }
  4698. });
  4699. });
  4700. };
  4701. mooc.prototype.runMoocTask = function (moocTask) {
  4702. var _this = this;
  4703. moocTask.addEventListener("reload", function () {
  4704. if (application_1.Application.App.config.auto) {
  4705. _this.runTask(moocTask);
  4706. }
  4707. clearTimeout(_this.timer);
  4708. });
  4709. moocTask.addEventListener("complete", function () {
  4710. application_1.Application.App.log.Warn("任务完成了");
  4711. alert("任务完成了");
  4712. });
  4713. moocTask.addEventListener("taskComplete", function (index, task) {
  4714. moocTask.SetTaskPointer(index + 1);
  4715. if (!application_1.Application.App.config.auto) {
  4716. return;
  4717. }
  4718. var interval = application_1.Application.App.config.interval;
  4719. application_1.Application.App.log.Info(interval + "分钟后自动切换下一个任务点");
  4720. _this.timer = setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
  4721. return __generator(this, function (_a) {
  4722. switch (_a.label) {
  4723. case 0: return [4 /*yield*/, task.Submit()];
  4724. case 1:
  4725. _a.sent();
  4726. return [4 /*yield*/, this.runTask(moocTask)];
  4727. case 2:
  4728. _a.sent();
  4729. return [2 /*return*/];
  4730. }
  4731. });
  4732. }); }, interval * 60000);
  4733. });
  4734. moocTask.addEventListener("error", function (msg) {
  4735. application_1.Application.App.log.Fatal(msg);
  4736. alert(msg);
  4737. });
  4738. };
  4739. mooc.prototype.runTask = function (moocTask) {
  4740. return __awaiter(this, void 0, void 0, function () {
  4741. var task;
  4742. return __generator(this, function (_a) {
  4743. switch (_a.label) {
  4744. case 0:
  4745. if (this.once) {
  4746. return [2 /*return*/];
  4747. }
  4748. this.once = true;
  4749. return [4 /*yield*/, moocTask.Next()];
  4750. case 1:
  4751. task = _a.sent();
  4752. _a.label = 2;
  4753. case 2:
  4754. if (!(task != null)) return [3 /*break*/, 9];
  4755. if (!task.Done()) return [3 /*break*/, 4];
  4756. return [4 /*yield*/, moocTask.Next()];
  4757. case 3:
  4758. task = _a.sent();
  4759. return [3 /*break*/, 2];
  4760. case 4:
  4761. if (!(application_1.Application.App.config.answer_ignore && task.Type() == "topic")) return [3 /*break*/, 6];
  4762. return [4 /*yield*/, moocTask.Next()];
  4763. case 5:
  4764. task = _a.sent();
  4765. return [3 /*break*/, 2];
  4766. case 6:
  4767. if (!application_1.Application.App.config.auto) return [3 /*break*/, 8];
  4768. return [4 /*yield*/, task.Start()];
  4769. case 7:
  4770. _a.sent();
  4771. _a.label = 8;
  4772. case 8:
  4773. this.nowTask = task;
  4774. return [3 /*break*/, 9];
  4775. case 9:
  4776. this.once = false;
  4777. return [2 /*return*/];
  4778. }
  4779. });
  4780. });
  4781. };
  4782. return mooc;
  4783. }());
  4784. exports.mooc = mooc;
  4785. /***/ }),
  4786. /***/ "./src/tampermonkey/cxmooc-pack.ts":
  4787. /*!*****************************************!*\
  4788. !*** ./src/tampermonkey/cxmooc-pack.ts ***!
  4789. \*****************************************/
  4790. /*! no static exports found */
  4791. /***/ (function(module, exports, __webpack_require__) {
  4792. "use strict";
  4793. Object.defineProperty(exports, "__esModule", { value: true });
  4794. var config_1 = __webpack_require__(/*! @App/internal/utils/config */ "./src/internal/utils/config.ts");
  4795. var log_1 = __webpack_require__(/*! @App/internal/utils/log */ "./src/internal/utils/log.ts");
  4796. var application_1 = __webpack_require__(/*! @App/internal/application */ "./src/internal/application.ts");
  4797. var mooc_1 = __webpack_require__(/*! @App/mooc/mooc */ "./src/mooc/mooc.ts");
  4798. var platform_1 = __webpack_require__(/*! @App/mooc/chaoxing/platform */ "./src/mooc/chaoxing/platform.ts");
  4799. var logger;
  4800. if (top == self) {
  4801. logger = new log_1.PageLog();
  4802. }
  4803. else {
  4804. logger = new log_1.ConsoleLog();
  4805. }
  4806. application_1.Application.GlobalContext = window.unsafeWindow;
  4807. var component = new Map().
  4808. set("config", new config_1.ChromeConfigItems(config_1.NewFrontendGetConfig())).
  4809. set("logger", logger);
  4810. var app = new application_1.Application(application_1.Frontend, new mooc_1.mooc(new platform_1.CxPlatform()), component);
  4811. app.run();
  4812. /***/ }),
  4813. /***/ "./src/views/common.ts":
  4814. /*!*****************************!*\
  4815. !*** ./src/views/common.ts ***!
  4816. \*****************************/
  4817. /*! no static exports found */
  4818. /***/ (function(module, exports) {
  4819. window.addEventListener("load", function () {
  4820. 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: 400px;\n color:#000;\n position: fixed;\n margin: 0 auto;\n display: block;\n font-size: 14px;\n border-radius: 4px;\n width: 420px;\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 border-top:0px;\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 border: 1px solid #d7d7d7;\n border-radius: 50px;\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";
  4821. var style = document.createElement("style");
  4822. style.innerHTML = css;
  4823. document.body.appendChild(style);
  4824. });
  4825. /***/ })
  4826. /******/ });
  4827. //# sourceMappingURL=tampermonkey-cxmooc.js.map
  4828. (function() {
  4829. 'use strict';
  4830. // 域名规则列表
  4831. var rules = {
  4832. black_rule: {
  4833. name: "black",
  4834. hook_eventNames: "",
  4835. unhook_eventNames: ""
  4836. },
  4837. default_rule: {
  4838. name: "default",
  4839. hook_eventNames: "contextmenu|select|selectstart|copy|cut|dragstart",
  4840. unhook_eventNames: "mousedown|mouseup|keydown|keyup",
  4841. dom0: true,
  4842. hook_addEventListener: true,
  4843. hook_preventDefault: true,
  4844. hook_set_returnValue: true,
  4845. add_css: true
  4846. }
  4847. };
  4848. // 域名列表
  4849. var lists = {
  4850. // 黑名单
  4851. black_list: [
  4852. /.*\.youtube\.com.*/,
  4853. /.*\.wikipedia\.org.*/,
  4854. /mail\.qq\.com.*/,
  4855. /translate\.google\..*/
  4856. ]
  4857. };
  4858. // 要处理的 event 列表
  4859. var hook_eventNames, unhook_eventNames, eventNames;
  4860. // 储存名称
  4861. var storageName = getRandStr('qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM', parseInt(Math.random() *
  4862. 12 + 8));
  4863. // 储存被 Hook 的函数
  4864. var EventTarget_addEventListener = EventTarget.prototype.addEventListener;
  4865. var document_addEventListener = document.addEventListener;
  4866. var Event_preventDefault = Event.prototype.preventDefault;
  4867. // Hook addEventListener proc
  4868. function addEventListener(type, func, useCapture) {
  4869. var _addEventListener = this === document ? document_addEventListener : EventTarget_addEventListener;
  4870. if (hook_eventNames.indexOf(type) >= 0) {
  4871. _addEventListener.apply(this, [type, returnTrue, useCapture]);
  4872. } else if (this && unhook_eventNames.indexOf(type) >= 0) {
  4873. var funcsName = storageName + type + (useCapture ? 't' : 'f');
  4874. if (this[funcsName] === undefined) {
  4875. this[funcsName] = [];
  4876. _addEventListener.apply(this, [type, useCapture ? unhook_t : unhook_f, useCapture]);
  4877. }
  4878. this[funcsName].push(func);
  4879. } else {
  4880. _addEventListener.apply(this, arguments);
  4881. }
  4882. }
  4883. // 清理循环
  4884. function clearLoop() {
  4885. var elements = getElements();
  4886. for (var i in elements) {
  4887. for (var j in eventNames) {
  4888. var name = 'on' + eventNames[j];
  4889. if (elements[i][name] !== null && elements[i][name] !== onxxx) {
  4890. if (unhook_eventNames.indexOf(eventNames[j]) >= 0) {
  4891. elements[i][storageName + name] = elements[i][name];
  4892. elements[i][name] = onxxx;
  4893. } else {
  4894. elements[i][name] = null;
  4895. }
  4896. }
  4897. }
  4898. }
  4899. }
  4900. // 返回true的函数
  4901. function returnTrue(e) {
  4902. return true;
  4903. }
  4904. function unhook_t(e) {
  4905. return unhook(e, this, storageName + e.type + 't');
  4906. }
  4907. function unhook_f(e) {
  4908. return unhook(e, this, storageName + e.type + 'f');
  4909. }
  4910. function unhook(e, self, funcsName) {
  4911. var list = self[funcsName];
  4912. for (var i in list) {
  4913. list[i](e);
  4914. }
  4915. e.returnValue = true;
  4916. return true;
  4917. }
  4918. function onxxx(e) {
  4919. var name = storageName + 'on' + e.type;
  4920. this[name](e);
  4921. e.returnValue = true;
  4922. return true;
  4923. }
  4924. // 获取随机字符串
  4925. function getRandStr(chs, len) {
  4926. var str = '';
  4927. while (len--) {
  4928. str += chs[parseInt(Math.random() * chs.length)];
  4929. }
  4930. return str;
  4931. }
  4932. // 获取所有元素 包括document
  4933. function getElements() {
  4934. var elements = Array.prototype.slice.call(document.getElementsByTagName('*'));
  4935. elements.push(document);
  4936. return elements;
  4937. }
  4938. // 添加css
  4939. function addStyle(css) {
  4940. var style = document.createElement('style');
  4941. style.innerHTML = css;
  4942. document.head.appendChild(style);
  4943. }
  4944. // 获取目标域名应该使用的规则
  4945. function getRule(url) {
  4946. function testUrl(list, url) {
  4947. for (var i in list) {
  4948. if (list[i].test(url)) {
  4949. return true;
  4950. }
  4951. }
  4952. return false;
  4953. }
  4954. if (testUrl(lists.black_list, url)) {
  4955. return rules.black_rule;
  4956. }
  4957. return rules.default_rule;
  4958. }
  4959. // 初始化
  4960. function init() {
  4961. // 获取当前域名的规则
  4962. var url = window.location.host + window.location.pathname;
  4963. var rule = getRule(url);
  4964. // 设置 event 列表
  4965. hook_eventNames = rule.hook_eventNames.split("|");
  4966. // TODO Allowed to return value
  4967. unhook_eventNames = rule.unhook_eventNames.split("|");
  4968. eventNames = hook_eventNames.concat(unhook_eventNames);
  4969. // 调用清理 DOM0 event 方法的循环
  4970. if (rule.dom0) {
  4971. setInterval(clearLoop, 30 * 1000);
  4972. setTimeout(clearLoop, 2500);
  4973. window.addEventListener('load', clearLoop, true);
  4974. clearLoop();
  4975. }
  4976. // hook addEventListener
  4977. if (rule.hook_addEventListener) {
  4978. EventTarget.prototype.addEventListener = addEventListener;
  4979. document.addEventListener = addEventListener;
  4980. }
  4981. // hook preventDefault
  4982. if (rule.hook_preventDefault) {
  4983. Event.prototype.preventDefault = function() {
  4984. if (eventNames.indexOf(this.type) < 0) {
  4985. Event_preventDefault.apply(this, arguments);
  4986. }
  4987. };
  4988. }
  4989. // Hook set returnValue
  4990. if (rule.hook_set_returnValue) {
  4991. Event.prototype.__defineSetter__('returnValue', function() {
  4992. if (this.returnValue !== true && eventNames.indexOf(this.type) >= 0) {
  4993. this.returnValue = true;
  4994. }
  4995. });
  4996. }
  4997. console.debug('url: ' + url, 'storageName:' + storageName, 'rule: ' + rule.name);
  4998. // 添加CSS
  4999. if (rule.add_css) {
  5000. addStyle('html, * {-webkit-user-select:text!important; -moz-user-select:text!important;}');
  5001. }
  5002. }
  5003. init();
  5004. })();

QingJ © 2025

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