超星慕课小工具4月24最新版

Margaret ·
更新时间:2024-11-13
· 721 次阅读

// ==UserScript== // @name 超星慕课小工具(黄金精神) // @namespace https://github.com/CodFrm/cxmooc-tools // @version 2.4.1 // @description 一个超星慕课刷课工具,火狐,谷歌,油猴支持.全自动任务,视频倍速秒过,作业考试题库,验证码自动打码(੧ᐛ੭挂科模式,启动) // @author CodFrm // @run-at document-start // @match *://*/mycourse/studentstudy?* // @match *://*/ztnodedetailcontroller/visitnodedetail?* // @match *://*/antispiderShowVerify.ac* // @match *://*/html/processVerify.ac?* // @match *://*/exam/test/reVersionPaperMarkContentNew?* // @match *://*/exam/test/reVersionTestStartNew?* // @match *://*/work/selectWorkQuestionYiPiYue?* // @match *://*/work/doHomeWorkNew?* // @match *://*/ananas/modules/*/index.html?* // @match *://*/exam/test?* // @match *://*/course/*.html?* // @grant GM_xmlhttpRequest // @grant GM_notification // @grant unsafeWindow // @license MIT // ==/UserScript== let config = { answer_ignore: false, //忽略题目,勾选此处将不会答题 auto: true, //全自动挂机,无需手动操作,即可自动观看视频等 interval: 2, //时间间隔,当任务点完成后,会等待2分钟然后跳转到下一个任务点 rand_answer: false, //随机答案,没有答案的题目将自动的生成一个答案 video_multiple: 1, //视频播放倍速,视频播放的倍数,建议不要改动,为1即可,这是危险的功能 video_mute: true, //视频静音,视频自动静音播放 vtoken: "", video_cdn: "公网1", //锁定视频播放源,为空为记录最后一次选中的源(公网1,公网2等) super_mode: true, //解锁flash弹幕视频等,详情请看文档 }; Object.keys(config).forEach(k => { localStorage[k] = config[k]; }); /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = "./src/tampermonkey/cxmooc-pack.ts"); /******/ }) /************************************************************************/ /******/ ({ /***/ "./src/config.ts": /*!***********************!*\ !*** ./src/config.ts ***! \***********************/ /*! exports provided: SystemConfig */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"SystemConfig\", function() { return SystemConfig; });\nvar SystemConfig = /** @class */ (function () {\r\n function SystemConfig() {\r\n }\r\n SystemConfig.version = 2.4;\r\n SystemConfig.url = \"https://cxmooc.wget.es/\";\r\n SystemConfig.hotVersion = \"2.4.0\";\r\n SystemConfig.match = [\r\n \"*://*/mycourse/studentstudy?*\",\r\n \"*://*/work/doHomeWorkNew?*\",\r\n \"*://*/work/selectWorkQuestionYiPiYue?*\",\r\n \"*://*/exam/test/reVersionTestStartNew?*\",\r\n \"*://*/ztnodedetailcontroller/visitnodedetail?*\",\r\n \"*://*/antispiderShowVerify.ac*\",\r\n \"*://*/html/processVerify.ac?*\",\r\n \"*://*/exam/test/reVersionPaperMarkContentNew?*\",\r\n \"*://*/ananas/modules/*/index.html?*\",\r\n \"*://*/exam/test?*\",\r\n \"*://*/course/*.html?*\",\r\n \"*://examh5.zhihuishu.com/stuExamWeb.html*\",\r\n \"*://onlineexamh5new.zhihuishu.com/stuExamWeb.html*\",\r\n \"*://studyh5.zhihuishu.com/videoStudy.html*\",\r\n \"*://www.icourse163.org/learn/*\",\r\n \"*://www.icourse163.org/spoc/learn/*\"\r\n ];\r\n return SystemConfig;\r\n}());\r\n\r\n\n\n//# sourceURL=webpack:///./src/config.ts?"); /***/ }), /***/ "./src/internal/app/question.ts": /*!**************************************!*\ !*** ./src/internal/app/question.ts ***! \**************************************/ /*! exports provided: PushAnswer, TopicStatusString, QuestionStatusString, SwitchTopicType, ToolsQuestionBank, ToolsQuestionBankFacade */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"PushAnswer\", function() { return PushAnswer; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"TopicStatusString\", function() { return TopicStatusString; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"QuestionStatusString\", function() { return QuestionStatusString; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"SwitchTopicType\", function() { return SwitchTopicType; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"ToolsQuestionBank\", function() { return ToolsQuestionBank; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"ToolsQuestionBankFacade\", function() { return ToolsQuestionBankFacade; });\n/* harmony import */ var _utils_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/utils */ \"./src/internal/utils/utils.ts\");\n/* harmony import */ var _App_config__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @App/config */ \"./src/config.ts\");\n/* harmony import */ var _application__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../application */ \"./src/internal/application.ts\");\n\r\n\r\n\r\nvar PushAnswer = /** @class */ (function () {\r\n function PushAnswer() {\r\n }\r\n PushAnswer.prototype.Equal = function (content1, content2) {\r\n return content1 == content2;\r\n };\r\n return PushAnswer;\r\n}());\r\n\r\nvar topicStatusMap = new Map();\r\ntopicStatusMap.set(\"ok\", \"搜索成功\").set(\"random\", \"随机答案\").set(\"no_support_random\", \"不支持的随机答案类型\").set(\"no_answer\", \"题库中没有搜索到答案\").set(\"no_match\", \"题库中没有符合的答案\");\r\nvar questionStatusMap = new Map();\r\nquestionStatusMap.set(\"success\", \"搜索成功\").set(\"network\", \"题库网络错误\").set(\"incomplete\", \"题库不全\").set(\"processing\", \"搜索中...\");\r\nfunction TopicStatusString(status) {\r\n return topicStatusMap.get(status) || \"未知错误\";\r\n}\r\nfunction QuestionStatusString(status) {\r\n return questionStatusMap.get(status) || \"未知错误\";\r\n}\r\nfunction SwitchTopicType(title) {\r\n switch (title) {\r\n case \"单选题\": {\r\n return 1;\r\n }\r\n case \"多选题\": {\r\n return 2;\r\n }\r\n case \"判断题\": {\r\n return 3;\r\n }\r\n case \"填空题\": {\r\n return 4;\r\n }\r\n default: {\r\n return null;\r\n }\r\n }\r\n}\r\n// 小工具题库\r\nvar ToolsQuestionBank = /** @class */ (function () {\r\n function ToolsQuestionBank(platform, info) {\r\n this.platform = platform;\r\n this.info = info;\r\n }\r\n ToolsQuestionBank.prototype.SetInfo = function (info) {\r\n this.info = info;\r\n };\r\n ToolsQuestionBank.prototype.GetInfo = function () {\r\n return encodeURIComponent(JSON.stringify(this.info));\r\n };\r\n ToolsQuestionBank.prototype.Answer = function (topic, resolve) {\r\n var _this = this;\r\n _application__WEBPACK_IMPORTED_MODULE_2__[\"Application\"].App.log.Debug(\"答案查询\", topic);\r\n var num = 10;\r\n var answer = new Array();\r\n var retStatus = \"success\";\r\n var next = function (index) {\r\n var body = \"info=\" + _this.GetInfo() + \"&\";\r\n var t = index;\r\n for (; t < index + num && t < topic.length; t++) {\r\n var val = topic[t];\r\n body += \"topic[\" + (t - index) + \"]=\" + encodeURIComponent((val.topic)) + \"&type[\" + (t - index) + \"]=\" + val.type + \"&\";\r\n }\r\n _utils_utils__WEBPACK_IMPORTED_MODULE_0__[\"HttpUtils\"].HttpPost(_App_config__WEBPACK_IMPORTED_MODULE_1__[\&quo t;SystemConfig\"].url + \"v2/answer?platform=\" + _this.platform, body, {\r\n json: true,\r\n success: function (result) {\r\n var status = \"success\";\r\n var tmpResult = new Array();\r\n for (var i = 0; i < result.length; i++) {\r\n if (result[i].result == undefined || result[i].result.length <= 0) {\r\n tmpResult.push({\r\n index: index + result[i].index,\r\n topic: result[i].topic,\r\n type: -1,\r\n status: \"no_answer\",\r\n answers: null,\r\n correct: null,\r\n Equal: _this.Equal,\r\n });\r\n status = \"incomplete\";\r\n continue;\r\n }\r\n var val = result[i].result[0];\r\n tmpResult.push({\r\n index: index + result[i].index,\r\n topic: val.topic,\r\n type: val.type,\r\n correct: val.correct,\r\n status: \"ok\",\r\n Equal: _this.Equal,\r\n });\r\n }\r\n answer = answer.concat(tmpResult);\r\n if (status != \"success\") {\r\n retStatus = status;\r\n }\r\n resolve({ status: \"processing\", answer: tmpResult });\r\n if (t < topic.length) {\r\n next(t);\r\n }\r\n else {\r\n return resolve({ status: retStatus, answer: answer });\r\n }\r\n },\r\n error: function () {\r\n return resolve({ status: \"network\", answer: answer });\r\n }\r\n });\r\n };\r\n next(0);\r\n };\r\n ToolsQuestionBank.prototype.Push = function (answer) {\r\n var _this = this;\r\n return new Promise(function (resolve) {\r\n _application__WEBPACK_IMPORTED_MODULE_2__[\"Application\"].App.log.Debug(\"采集提交\", answer);\r\n _utils_utils__WEBPACK_IMPORTED_MODULE_0__[\"HttpUtils\"].HttpPost(_App_config__WEBPACK_IMPORTED_MODULE_1__[\"SystemConfig\"].url + \"answer?platform=\" + _this.platform, \"info=\" + _this.GetInfo() + \"&data=\" + encodeURIComponent(JSON.stringify(answer)), {\r\n json: true,\r\n success: function (result) {\r\n _application__WEBPACK_IMPORTED_MODULE_2__[\"Application\"].App.log.Info(\"答案自动记录成功,成功获得\" + result.add_token_num + \"个打码数,剩余数量:\" + result.token_num);\r\n resolve(\"success\");\r\n },\r\n error: function () {\r\n resolve(\"network\");\r\n }\r\n });\r\n });\r\n };\r\n ToolsQuestionBank.prototype.Equal = function (content1, content2) {\r\n return Object(_utils_utils__WEBPACK_IMPORTED_MODULE_0__[\"removeHTML\"])(content1) == Object(_utils_utils__WEBPACK_IMPORTED_MODULE_0__[\"removeHTML\"])(content2);\r\n };\r\n ToolsQuestionBank.prototype.CheckCourse = function (info) {\r\n var _this = this;\r\n return new Promise(function (resolve) {\r\n info = info || [_this.info];\r\n _utils_utils__WEBPACK_IMPORTED_MODULE_0__[\"HttpUtils\"].HttpPost(_App_config__WEBPACK_IMPORTED_MODULE_1__[\"SystemConfig\"] .url + \"v2/check?platform=\" + _this.platform, \"info=\" + encodeURIComponent(JSON.stringify(info)), {\r\n success: function () {\r\n //TODO:课程题目数量\r\n resolve(0);\r\n }, error: function () {\r\n resolve(-1);\r\n }\r\n });\r\n resolve();\r\n });\r\n };\r\n return ToolsQuestionBank;\r\n}());\r\n\r\nvar ToolsQuestionBankFacade = /** @class */ (function () {\r\n function ToolsQuestionBankFacade(platform, info) {\r\n if (typeof platform == \"string\") {\r\n this.bank = new ToolsQuestionBank(platform, info);\r\n }\r\n else {\r\n this.bank = platform;\r\n }\r\n this.question = new Array();\r\n }\r\n ToolsQuestionBankFacade.prototype.ClearQuestion = function () {\r\n this.question = new Array();\r\n };\r\n ToolsQuestionBankFacade.prototype.AddQuestion = function (q) {\r\n this.question.push(q);\r\n };\r\n ToolsQuestionBankFacade.prototype.Answer = function (callback) {\r\n var _this = this;\r\n var topic = new Array();\r\n this.question.forEach(function (val) {\r\n var type = val.GetType();\r\n if (type == -1) {\r\n return;\r\n }\r\n topic.push({\r\n topic: (val.GetTopic()),\r\n type: type,\r\n });\r\n });\r\n var status = \"success\";\r\n this.bank.Answer(topic, function (ret) {\r\n if (ret.status != \"processing\") {\r\n _application__WEBPACK_IMPORTED_MODULE_2__[\"Application\"].App.log.Debug(\"题库返回\", ret);\r\n if (ret.status != \"success\" || status == \"success\") {\r\n return callback(ret.status);\r\n }\r\n return callback(status);\r\n }\r\n for (var i = 0; i < ret.answer.length; i++) {\r\n var answer = ret.answer[i];\r\n var question = _this.question[answer.index];\r\n var tmpStatus = answer.status;\r\n if (answer.status == \"no_answer\") {\r\n status = _this.randAnswer(status, tmpStatus, question);\r\n continue;\r\n }\r\n if (answer.type != question.GetType()) {\r\n tmpStatus = \"no_match\";\r\n }\r\n else {\r\n tmpStatus = question.Fill(answer);\r\n }\r\n if (tmpStatus == \"no_match\") {\r\n status = _this.randAnswer(status, tmpStatus, question);\r\n continue;\r\n }\r\n question.SetStatus(tmpStatus);\r\n }\r\n });\r\n };\r\n ToolsQuestionBankFacade.prototype.randAnswer = function (status, tmpStatus, question) {\r\n if (_application__WEBPACK_IMPORTED_MODULE_2__[\"Application\"].App.config.rand_answer) {\r\n tmpStatus = question.Random();\r\n }\r\n else {\r\n status = \"incomplete\";\r\n }\r\n if (tmpStatus == \"no_support_random\") {\r\n status = \"incomplete\";\r\n }\r\n question.SetStatus(tmpStatus);\r\n return status;\r\n };\r\n ToolsQuestionBankFacade.prototype.Push = function (callback) {\r\n var answer = new Array();\r\n this.question.forEach(function (val) {\r\n var correct = val.Correct();\r\n if (correct == null || correct.correct == null || correct.type == -1) {\r\n return;\r\n }\r\n correct.topic = correct.topic;\r\n correct.answers = correct.answers;\r\n correct.correct = correct.correct;\r\n answer.push(correct);\r\n });\r\n this. bank.Push(answer).then(function (ret) {\r\n _application__WEBPACK_IMPORTED_MODULE_2__[\"Application\"].App.log.Debug(\"题库返回\", ret);\r\n return callback(ret);\r\n });\r\n };\r\n ToolsQuestionBankFacade.prototype.dealOption = function (options) {\r\n for (var i = 0; i 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n};\r\n\r\n\r\n\r\nvar Backend = \"backend\";\r\nvar Frontend = \"frontend\";\r\nvar Content = \"content\";\r\nvar AppName = \"cxmooc-tools\";\r\nvar Application = /** @class */ (function () {\r\n function Application(runEnv, launcher, component) {\r\n Application.app = this;\r\n Application.runEnv = runEnv;\r\n this.runEnvSwitch(runEnv);\r\n this.launcher = launcher;\r\n this.component = component;\r\n }\r\n Object.defineProperty(Application, \"App\", {\r\n get: function () {\r\n return Application.app;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Application.prototype, \"debug\", {\r\n get: function () {\r\n return \"development\" == \"development\";\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Application.prototype, \"prod\", {\r\n get: function () {\r\n return \"development\" == \"production\";\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Application.prototype, \"config\", {\r\n get: function () {\r\n return this.component.get(\"config\");\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Application.prototype, \"log\", {\r\n get: function () {\r\n return this.component.get(\"logger\");\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Application.prototype.run = function () {\r\n this.launcher.start();\r\n };\r\n Object.defineProperty(Application.prototype, \"IsFrontend\", {\r\n get: function () {\r\n return Application.IsFrontend;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Application.prototype, \"IsBackend\", {\r\n get: function () {\r\n return Application.IsBackend;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(Application.prototype, \"IsContent\", {\r\n get: function () {\r\n return Application.IsContent;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Application.prototype.runEnvSwitch = function (env) {\r\n switch (env) {\r\n case Frontend:\r\n Application.IsFrontend = true;\r\n break;\r\n case Backend:\r\n Application.IsBackend = true;\r\n break;\r\n case Content:\r\n Application.IsContent = true;\r\n break;\r\n }\r\n ;\r\n };\r\n Object.defineProperty(Application.prototype, \"Client\", {\r\n get: function () {\r\n if (Application.IsFrontend) {\r\n return Object(_utils_message__WEBPACK_IMPORTED_MODULE_0__[\"NewChromeClientMessage\"])(AppName);\r\n }\r\n return Object(_utils_message__WEBPACK_IMPORTED_MODULE_0__[\"NewExtensionClientMessage\"])(AppName);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Application.CheckUpdate = function (callback) {\r\n if (Application.IsContent) {\r\n chrome.storage.local.get([\"version\", \"enforce\", \"hotversion\", \"url\"], function (item) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0: return [4 /*yield*/, callback((_App_config__WEBPACK_IMPORTED_MODULE_2__[\"SystemConfig\"].version < item.version), item)];\r\n case 1:\r\n _a.sent();\r\n return [2 /*return*/];\r\n }\r\n });\r\n });\r\n });\r\n return;\r\n }\r\n _utils_utils__WEBPACK_IMPORTED_MODULE_1__[\"HttpUtils\"].HttpGet(_App_config__WEBPACK_IMPORTED_MODULE_2__[\"SystemConfig\"].url + \"update?ver=\" + _App_config__WEBPACK_IMPORTED_MODULE_2__[\"SystemConfig\"].version, {\r\n json: true,\r\n success: function (json) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var data;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n data = {\r\n version: json.version,\r\n url: json.url,\r\n enforce: json.enforce,\r\n hotversion: json.hotversion,\r\n injection: json.injection,\r\n };\r\n chrome.storage.local.set(data);\r\n return [4 /*yield*/, callback((_App_config__WEBPACK_IMPORTED_MODULE_2__[\"SystemConfig\"].version < data.version), data)];\r\n case 1:\r\n _a.sent();\r\n return [2 /*return*/];\r\n }\r\n });\r\n });\r\n }, error: function () {\r\n return __awaiter(this, void 0, void 0, function () {\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0: return [4 /*yield*/, callback(false, undefined)];\r\n case 1:\r\n _a.sent();\r\n return [2 /*return*/];\r\n }\r\n });\r\n });\r\n }\r\n });\r\n };\r\n return Application;\r\n}());\r\n\r\n\n\n//# sourceURL=webpack:///./src/internal/application.ts?"); /***/ }), /***/ "./src/internal/utils/config.ts": /*!**************************************!*\ !*** ./src/internal/utils/config.ts ***! \**************************************/ /*! exports provided: ChromeConfigItems, NewBackendConfig, NewFrontendGetConfig */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"ChromeConfigItems\", function() { return ChromeConfigItems; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"NewBackendConfig\", function() { return NewBackendConfig; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"NewFrontendGetConfig\", function() { return NewFrontendGetConfig; });\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils */ \"./src/internal/utils/utils.ts\");\n/* harmony import */ var _application__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../application */ \"./src/internal/application.ts\");\n\r\n\r\nvar ChromeConfigItems = /** @class */ (function () {\r\n function ChromeConfigItems(getConfig) {\r\n this.getConfig = getConfig;\r\n }\r\n ChromeConfigItems.prototype.GetConfig = function (key) {\r\n return this.getConfig.GetConfig(key);\r\n };\r\n ChromeConfigItems.prototype.Watch = function (key, callback) {\r\n this.getConfig.Watch(key, callback);\r\n };\r\n ChromeConfigItems.prototype.bool = function (val) {\r\n if (typeof val == \"boolean\") {\r\n return val;\r\n }\r\n return val == \"true\";\r\n };\r\n Object.defineProperty(ChromeConfigItems.prototype, \"super_mode\", {\r\n get: function () {\r\n return this.bool(this.getConfig.GetConfig(\"super_mode\"));\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ChromeConfigItems.prototype, \"vtoken\", {\r\n get: function () {\r\n return this.getConfig.GetConfig(\"vtoken\");\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ChromeConfigItems.prototype, \"rand_answer\", {\r\n get: function () {\r\n return this.bool(this.getConfig.GetConfig(\"rand_answer\"));\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ChromeConfigItems.prototype, \"auto\", {\r\n get: function () {\r\n return this.bool(this.getConfig.GetConfig(\"auto\"));\r\n },\r\n set: function (val) {\r\n localStorage[\"auto\"] = val;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ChromeConfigItems.prototype, \"video_mute\", {\r\n get: function () {\r\n return this.bool(this.getConfig.GetConfig(\"video_mute\"));\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ChromeConfigItems.prototype, \"answer_ignore\", {\r\n get: function () {\r\n return this.bool(this.getConfig.GetConfig(\"answer_ignore\"));\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ChromeConfigItems.prototype, \"video_cdn\", {\r\n get: function () {\r\n return this.getConfig.GetConfig(\"video_cdn\");\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ChromeConfigItems.prototype, \"video_multiple\", {\r\n get: function () {\r\n return this.getConfig.GetConfig(\"video_multiple\");\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(ChromeConfigItems.prototype, \"interval\", {\r\n get: function () {\r\n var interval = (this.getConfig.GetConfig(\"interval\") || 0.1) * 100;\r\n return Math.floor(Object(_utils__WEBPACK_IMPORTED_MODULE_0__[\"randNumber\"])(interval - interval / 2, interval + interval / 2)) / 100;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n return ChromeConfigItems;\r\n}());\r\n\r\n// 后台环境中使用\r\nfunction NewBackendConfig() {\r\n return new backendConfig();\r\n}\r\nvar backendConfig = /** @class */ (function () {\r\n function backendConfig() {\r\n }\r\n backendConfig.prototype.GetConfig = function (key) {\r\n return new Promise(function (resolve) { return (chrome.storage.sync.get(key, function (value) {\r\n if (value.hasOwnProperty(key)) {\r\n resolve(value[key]);\r\n }\r\n else {\r\n resolve(undefined);\r\n }\r\n })); });\r\n };\r\n backendConfig.prototype.Watch = function (key, callback) {\r\n throw new Error(\"Method not implemented.\");\r\n };\r\n backendConfig.prototype.SetConfig = function (key, val) {\r\n return new Promise(function (resolve) {\r\n var info = {};\r\n info[key] = val;\r\n chrome.storage.sync.set(info, function () {\r\n chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {\r\n chrome.tabs.sendMessage(tabs[0].id, { type: \"cxconfig\", key: key, value: val });\r\n });\r\n resolve();\r\n });\r\n });\r\n };\r\n return backendConfig;\r\n}());\r\n// 前端环境使用\r\nfunction NewFrontendGetConfig() {\r\n return new frontendGetConfig();\r\n}\r\nvar frontendGetConfig = /** @class */ (function () {\r\n function frontendGetConfig() {\r\n window.addEventListener('message', function (event) {\r\n if (event.data.type && event.data.type == \"cxconfig\") {\r\n _application__WEBPACK_IMPORTED_MODULE_1__[\"Application\"].App.log.Info(\"配置更新:\" + event.data.key + \"=\" + event.data.value);\r\n localStorage[event.data.key] = event.data.value;\r\n }\r\n });\r\n }\r\n frontendGetConfig.prototype.GetConfig = function (key) {\r\n return localStorage[key];\r\n };\r\n frontendGetConfig.prototype.Watch = function (key, callback) {\r\n var _this = this;\r\n if (typeof key == \"string\") {\r\n this.setWatchMap(key, callback);\r\n return;\r\n }\r\n key.forEach(function (val, index) {\r\n _this.setWatchMap(val, callback);\r\n });\r\n };\r\n frontendGetConfig.prototype.setWatchMap = function (key, callback) {\r\n //TODO: 监控配置项更新\r\n };\r\n return frontendGetConfig;\r\n}());\r\n\n\n//# sourceURL=webpack:///./src/internal/utils/config.ts?"); /***/ }), /***/ "./src/internal/utils/hook.ts": /*!************************************!*\ !*** ./src/internal/utils/hook.ts ***! \************************************/ /*! exports provided: Hook */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"Hook\", function() { return Hook; });\n/* harmony import */ var _App_internal_application__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @App/internal/application */ \"./src/internal/application.ts\");\n\r\nvar Hook = /** @class */ (function () {\r\n function Hook(func, context) {\r\n this.context = context || window;\r\n this.func = func;\r\n }\r\n Hook.prototype.Middleware = function (call) {\r\n var name;\r\n if (typeof this.func == \"string\") {\r\n name = this.func;\r\n }\r\n else {\r\n name = this.func.name;\r\n }\r\n var old = this.context[name];\r\n this.context[name] = function () {\r\n var args = [old];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i + 1] = arguments[_i];\r\n }\r\n return call.apply(this, args);\r\n };\r\n };\r\n Hook.HookAjaxRespond = function (url, call) {\r\n var _this = this;\r\n if (!this.once) {\r\n this.match_list = new Map();\r\n var self_1 = this;\r\n var hookXMLHttpRequest = new Hook(\"open\", _App_internal_application__WEBPACK_IMPORTED_MODULE_0__[\"Application\"].GlobalContext.XMLHttpRequest.prototype);\r\n hookXMLHttpRequest.Middleware(function (next) {\r\n var _this = this;\r\n var args = [];\r\n for (var _a = 1; _a < arguments.length; _a++) {\r\n args[_a - 1] = arguments[_a];\r\n }\r\n self_1.match_list.forEach(function (val, key) {\r\n if (args[1].indexOf(key) != -1) {\r\n Object.defineProperty(_this, \"responseText\", {\r\n configurable: true,\r\n get: function () {\r\n return val.call(this, args[1], this.response);\r\n }\r\n });\r\n }\r\n });\r\n return next.apply(this, args);\r\n });\r\n this.once = true;\r\n }\r\n if (typeof url == \"string\") {\r\n this.match_list.set(url, call);\r\n }\r\n else {\r\n url.forEach(function (v) {\r\n _this.match_list.set(v, call);\r\n });\r\n }\r\n };\r\n return Hook;\r\n}());\r\n\r\n\n\n//# sourceURL=webpack:///./src/internal/utils/hook.ts?"); /***/ }), /***/ "./src/internal/utils/log.ts": /*!***********************************!*\ !*** ./src/internal/utils/log.ts ***! \***********************************/ /*! exports provided: ConsoleLog, PageLog, EmptyLog */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"ConsoleLog\", function() { return ConsoleLog; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"PageLog\", function() { return PageLog; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"EmptyLog\", function() { return EmptyLog; });\n/* harmony import */ var _application__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../application */ \"./src/internal/application.ts\");\n/* harmony import */ var _views_common__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../views/common */ \"./src/views/common.ts\");\n/* harmony import */ var _views_common__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_views_common__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var _App_internal_utils_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @App/internal/utils/utils */ \"./src/internal/utils/utils.ts\");\nvar __spreadArrays = (undefined && undefined.__spreadArrays) || function () {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\n\r\n\r\nvar ConsoleLog = /** @class */ (function () {\r\n function ConsoleLog() {\r\n }\r\n ConsoleLog.prototype.getNowTime = function () {\r\n var time = new Date();\r\n return time.getHours() + \":\" + time.getMinutes() + \":\" + time.getSeconds();\r\n };\r\n ConsoleLog.prototype.Debug = function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n _application__WEBPACK_IMPORTED_MODULE_0__[\"Application\"].App.debug && console.info.apply(console, __spreadArrays([\"[debug\", this.getNowTime(), \"]\"], args));\r\n return this;\r\n };\r\n ConsoleLog.prototype.Info = function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n _application__WEBPACK_IMPORTED_MODULE_0__[\"Application\"].App.debug && console.info.apply(console, __spreadArrays([\"[info\", this.getNowTime(), \"]\"], args));\r\n return this;\r\n };\r\n ConsoleLog.prototype.Warn = function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n console.warn.apply(console, __spreadArrays([\"[warn\", this.getNowTime(), \"]\"], args));\r\n return this;\r\n };\r\n ConsoleLog.prototype.Error = function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n console.error.apply(console, __spreadArrays([\"[error\", this.getNowTime(), \"]\"], args));\r\n return this;\r\n };\r\n ConsoleLog.prototype.Fatal = function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n console.error.apply(console, __spreadArrays([\"[fatal\", this.getNowTime(), \"]\"], args));\r\n return this;\r\n };\r\n return ConsoleLog;\r\n}());\r\n\r\nvar PageLog = /** @class */ (function () {\r\n function PageLog() {\r\n var _this = this;\r\n this.el = undefined;\r\n window.addEventListener(\"load\", function () {\r\n _this.div = document.createElement(\"div\");\r\n // 主要布局\r\n _this.div.innerHTML = \& quot;\\n
\\n \\u5C0F\\u5DE5\\u5177\\u901A\\u77E5\\u6761 \\n \\n x\\n
\\n
\\n
\\n
\\n \";\r\n _this.div.className = \"tools-logger-panel\";\r\n document.body.appendChild(_this.div);\r\n _this.el = _this.div.querySelector(\".tools-notice-content\");\r\n _this.div.querySelector(\".close\").onclick = function () {\r\n _this.el = undefined;\r\n _this.div.remove();\r\n };\r\n var checkbox = _this.div.querySelector(\"#checkbox\");\r\n localStorage[\"is_notify\"] = localStorage[\"is_notify\"] || \"true\";\r\n checkbox.checked = localStorage[\"is_notify\"] == \"true\";\r\n if (!checkbox.checked) {\r\n checkbox.removeAttribute(\"checked\");\r\n }\r\n checkbox.addEventListener(\"change\", function () {\r\n localStorage[\"is_notify\"] = this.checked;\r\n });\r\n setTimeout(function () {\r\n _this.Info(\"233\");\r\n }, 1000);\r\n });\r\n }\r\n PageLog.prototype.getNowTime = function () {\r\n var time = new Date();\r\n return time.getHours() + \":\" + time.getMinutes() + \":\" + time.getSeconds();\r\n };\r\n PageLog.prototype.first = function (text, color, background) {\r\n var new_log = document.createElement(\"div\");\r\n new_log.innerHTML = \"\\n
\\n

\" + text + \"

\\n
\\n \";\r\n //插入第一个元素前\r\n var first = document.getElementsByClassName(\"tools-notice-content\")[0].getElementsByTagName(\"div\");\r\n document.querySelector(\".tools-notice-content\").insertBefore(new_log, first[0]);\r\n };\r\n PageLog.prototype.toStr = function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n var text = \"\";\r\n for (var i = 0; i < args.length; i++) {\r\n if (typeof args[i] == \"object\") {\r\n text += JSON.stringify(args[i]) + \"\\n\";\r\n }\r\n else {\r\n text += args[i] + \"\\n\";\r\n }\r\n }\r\n return text.substring(0, text.length - 1);\r\n };\r\n PageLog.prototype.Debug = function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n console.info.apply(console, __spreadArrays([\"[debug\", this.getNowTime(), \"]\"], args));\r\n return this;\r\n };\r\n PageLog.prototype.Info = function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n var text = this.toStr.apply(this, args);\r\n // 判断选中状态是否发送桌面通知\r\n if (this.el) {\r\n this.first(text, \"#409EFF\", \"rgba(121, 187, 255, 0.2)\");\r\n }\r\n else {\r\n console.info.apply(console, __spreadArrays([\"[info\", this.getNowTime(), \"]\"], args));\r\n }\r\n return this;\r\n };\r\n PageLog.prototype.Warn = function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n var text = this.toStr.apply(this, args);\r\n if (this.el) {\r\n this.first(text, \"#5C3C00\", \"rgba(250, 236, 216, 0.4)\");\r\n }\r\n else {\r\ n console.warn.apply(console, __spreadArrays([\"[warn\", this.getNowTime(), \"]\"], args));\r\n }\r\n if (document.hidden && localStorage[\"is_notify\"] == \"true\") {\r\n Object(_App_internal_utils_utils__WEBPACK_IMPORTED_MODULE_2__[\"Noifications\"])({\r\n title: \"超星慕课小工具\",\r\n text: text + \"\\n3秒后自动关闭\",\r\n timeout: 3000,\r\n });\r\n }\r\n return this;\r\n };\r\n PageLog.prototype.Error = function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n var text = this.toStr.apply(this, args);\r\n if (this.el) {\r\n this.first(text, \"#ff7879\", \"rgba(253, 226, 226, 0.5)\");\r\n }\r\n else {\r\n console.error.apply(console, __spreadArrays([\"[error\", this.getNowTime(), \"]\"], args));\r\n }\r\n if (localStorage[\"is_notify\"] == \"true\") {\r\n Object(_App_internal_utils_utils__WEBPACK_IMPORTED_MODULE_2__[\"Noifications\"])({\r\n title: \"超星慕课小工具\",\r\n text: text,\r\n });\r\n }\r\n return this;\r\n };\r\n PageLog.prototype.Fatal = function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n var text = this.toStr.apply(this, args);\r\n if (this.el) {\r\n this.first(text, \"#ff0000\", \"rgba(253,162,169,0.5)\");\r\n }\r\n else {\r\n console.error.apply(console, __spreadArrays([\"[fatal\", this.getNowTime(), \"]\"], args));\r\n }\r\n Object(_App_internal_utils_utils__WEBPACK_IMPORTED_MODULE_2__[\"Noifications\"])({\r\n title: \"超星慕课小工具\",\r\n text: text,\r\n });\r\n return this;\r\n };\r\n return PageLog;\r\n}());\r\n\r\nvar EmptyLog = /** @class */ (function () {\r\n function EmptyLog() {\r\n }\r\n EmptyLog.prototype.Debug = function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n return this;\r\n };\r\n EmptyLog.prototype.Info = function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n return this;\r\n };\r\n EmptyLog.prototype.Warn = function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n return this;\r\n };\r\n EmptyLog.prototype.Error = function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n return this;\r\n };\r\n EmptyLog.prototype.Fatal = function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n return this;\r\n };\r\n return EmptyLog;\r\n}());\r\n\r\n\n\n//# sourceURL=webpack:///./src/internal/utils/log.ts?"); /***/ }), /***/ "./src/internal/utils/message.ts": /*!***************************************!*\ !*** ./src/internal/utils/message.ts ***! \***************************************/ /*! exports provided: NewExtensionServerMessage, NewExtensionClientMessage, NewChromeServerMessage, NewChromeClientMessage */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"NewExtensionServerMessage\", function() { return NewExtensionServerMessage; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"NewExtensionClientMessage\", function() { return NewExtensionClientMessage; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"NewChromeServerMessage\", function() { return NewChromeServerMessage; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"NewChromeClientMessage\", function() { return NewChromeClientMessage; });\nvar __extends = (undefined && undefined.__extends) || (function () {\r\n var extendStatics = function (d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n };\r\n return function (d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\nfunction NewExtensionServerMessage(port) {\r\n return new extensionServerMessage(port);\r\n}\r\nvar extensionServerMessage = /** @class */ (function () {\r\n function extensionServerMessage(port) {\r\n this.port = port;\r\n this.recv();\r\n }\r\n extensionServerMessage.prototype.recv = function () {\r\n var _this = this;\r\n //监听消息\r\n chrome.runtime.onConnect.addListener(function (port) {\r\n if (port.name != _this.port) {\r\n return;\r\n }\r\n port.onMessage.addListener(function (request) {\r\n _this.acceptCallback(new extensionClientMessage(port), request);\r\n });\r\n });\r\n };\r\n extensionServerMessage.prototype.Accept = function (callback) {\r\n this.acceptCallback = callback;\r\n };\r\n return extensionServerMessage;\r\n}());\r\nvar msg = /** @class */ (function () {\r\n function msg(tag) {\r\n this.tag = tag;\r\n }\r\n msg.prototype.Recv = function (callback) {\r\n this.recvCallback = callback;\r\n };\r\n return msg;\r\n}());\r\n// 扩展中使用\r\nfunction NewExtensionClientMessage(tag) {\r\n return new extensionClientMessage(tag);\r\n}\r\nvar extensionClientMessage = /** @class */ (function (_super) {\r\n __extends(extensionClientMessage, _super);\r\n function extensionClientMessage(param) {\r\n var _this = this;\r\n if (typeof param === 'string') {\r\n _this = _super.call(this, param) || this;\r\n _this.connect();\r\n }\r\n else {\r\n _this.conn = param;\r\n }\r\n _this.recv();\r\n return _this;\r\n }\r\n extensionClientMessage.prototype.connect = function () {\r\n this.conn = chrome.runtime.connect({ name: this.tag });\r\n };\r\n extensionClientMessage.prototype.recv = function () {\r\n var _this = this;\r\n this.conn.onMessage.addListener(function (response) {\r\n _this.recvCallback(response);\r\n });\r\n };\r\n extensionClientMessage.prototype.Send = function (msg) {\r\n this.conn.postMessage(msg);\r\n };\r\n return extensionClientMessage;\r\n}(msg));\r\n// 浏览器中使用\r\nfunction NewChromeServerMessage(tag) {\r\n return new chromeServerMessage(tag);\r\n}\r\nvar chromeServerMessage = /** @class */ (function () {\r\n function chromeServerMessage(tag) {\r\n this.tag = tag;\r\n this.recv();\r\n }\r\n chromeServerMessage.prototype.recv = function () {\r\n var _this = this;\r\n window.addEventListener('message', function (event) {\r\n if (event.data.tag == _this.tag && event.data.conn_tag && event.data.source == \"client\") {\r\n _this.acceptCallback(new chromeClientMessage(_this.tag, event.data.conn_tag), event.data.msg);\r\n }\r\n });\r\n };\r\n chromeServerMessage.prototype.Accept = function (callback) {\r\n this.acceptCallback = callback;\r\n };\r\n return chromeServerMessage;\r\n}());\r\nfunction NewChromeClientMessage(tag) {\r\n return new chromeClientMessage(tag);\r\n}\r\nvar chromeClientMessage = /** @class */ (function (_super) {\r\n __extends(chromeClientMessage, _super);\r\n function chromeClientMessage(tag, conn) {\r\n var _this = this;\r\n if (conn !== undefined) {\r\n _this = _super.call(this, tag) || this;\r\n _this.connTag = conn;\r\n _this.source = \"server\";\r\n }\r\n else {\r\n _this = _super.call(this, tag) || this;\r\n _this.connect();\r\n _this.source = \"client\";\r\n }\r\n return _this;\r\n }\r\n chromeClientMessage.prototype.connect = function () {\r\n var _this = this;\r\n this.connTag = Math.random();\r\n window.addEventListener('message', function (event) {\r\n if (event.data.tag == _this.tag && event.data.conn_tag == _this.connTag && event.data.source == \"server\") {\r\n _this.recvCallback && _this.recvCallback(event.data.msg);\r\n }\r\n });\r\n };\r\n chromeClientMessage.prototype.Send = function (msg) {\r\n window.postMessage({ tag: this.tag, conn_tag: this.connTag, msg: msg, source: this.source }, '*');\r\n };\r\n return chromeClientMessage;\r\n}(msg));\r\n\n\n//# sourceURL=webpack:///./src/internal/utils/message.ts?"); /***/ }), /***/ "./src/internal/utils/utils.ts": /*!*************************************!*\ !*** ./src/internal/utils/utils.ts ***! \*************************************/ /*! exports provided: HttpUtils, Injected, InjectedBySrc, syncGetChromeStorageLocal, syncSetChromeStorageLocal, RemoveInjected, randNumber, createBtn, get, post, removeHTMLTag, removeHTML, substrex, dealHotVersion, protocolPrompt, getImageBase64, isPhone, Noifications */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"HttpUtils\", function() { return HttpUtils; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"Injected\", function() { return Injected; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"InjectedBySrc\", function() { return InjectedBySrc; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"syncGetChromeStorageLocal\", function() { return syncGetChromeStorageLocal; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"syncSetChromeStorageLocal\", function() { return syncSetChromeStorageLocal; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"RemoveInjected\", function() { return RemoveInjected; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"randNumber\", function() { return randNumber; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"createBtn\", function() { return createBtn; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"get\", function() { return get; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"post\", function() { return post; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"removeHTMLTag\", function() { return removeHTMLTag; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"removeHTML\", function() { return removeHTML; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"substrex\", function() { return substrex; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"dealHotVersion\", function() { return dealHotVersion; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"protocolPrompt\", function() { return protocolPrompt; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"getImageBase64\", function() { return getImageBase64; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"isPhone\", function() { return isPhone; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"Noifications\", function() { return Noifications; });\n/* harmony import */ var _application__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../application */ \"./src/internal/application.ts\");\n/* harmony import */ var _App_config__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @App/config */ \"./src/config.ts\");\n\r\n\r\nvar HttpUtils = /** @class */ (function () {\r\n function HttpUtils() {\r\n }\r\n HttpUtils.Request = function (info) {\r\n if (_application__WEBPACK_IMPORTED_MODULE_0__[\"Application\"].App.IsBackend) {\r\n fetch(info.url, info).then(function (body) {\r\n if (info.json) {\r\n return body.json();\r\n }\r\n else {\r\n return body.text();\r\n }\r\n }).then(function (body) {\r\n info.success && info.success(body);\r\n }).catch(function () {\r\n info.error && info.error();\r\n });\r\n return;\r\n }\r\n HttpUtils.crossDomainRequest(info);\r\n };\r\n HttpUtils.errorCode = function (ret) {\r\n if (!ret.code) {\r\n return false;\r\n }\r\n switch (ret.code) {\r\n case -1: {\r\n _application__WEBPACK_IMPORTED_MODULE_0__[\"Application\"].App.log.Info(ret.msg);\r\n break;\r\n }\r\n case -2: {\r\n _application__WEBPACK_IMPORTED_MODULE_0__[\ "Application\"].App.log.Warn(ret.msg);\r\n break;\r\n }\r\n default: {\r\n return false;\r\n }\r\n }\r\n return true;\r\n };\r\n HttpUtils.crossDomainRequest = function (info) {\r\n if (window.hasOwnProperty('GM_xmlhttpRequest')) {\r\n //兼容油猴\r\n info.data = info.body;\r\n info.onreadystatechange = function (response) {\r\n if (response.readyState == 4) {\r\n if (response.status == 200) {\r\n if (info.json) {\r\n var ret = JSON.parse(response.responseText);\r\n if (HttpUtils.errorCode(ret)) {\r\n info.error && info.error();\r\n return;\r\n }\r\n info.success && info.success(ret);\r\n }\r\n else {\r\n info.success && info.success(response.responseText);\r\n }\r\n }\r\n else {\r\n info.error && info.error();\r\n }\r\n }\r\n };\r\n window.GM_xmlhttpRequest(info);\r\n }\r\n else {\r\n var client = _application__WEBPACK_IMPORTED_MODULE_0__[\"Application\"].App.Client;\r\n client.Recv(function (data) {\r\n if (data.code == 0) {\r\n if (info.json) {\r\n if (HttpUtils.errorCode(data.body)) {\r\n info.error && info.error();\r\n return;\r\n }\r\n }\r\n info.success && info.success(data.body);\r\n }\r\n else {\r\n info.error && info.error();\r\n }\r\n });\r\n client.Send({\r\n type: \"GM_xmlhttpRequest\", info: {\r\n url: info.url,\r\n method: info.method,\r\n json: info.json,\r\n body: info.body,\r\n headers: info.headers,\r\n }\r\n });\r\n }\r\n };\r\n HttpUtils.HttpGet = function (url, info) {\r\n info.url = url;\r\n this.Request(info);\r\n };\r\n HttpUtils.HttpPost = function (url, body, info) {\r\n info.url = url;\r\n info.body = body;\r\n if (!info.headers) {\r\n info.headers = {};\r\n }\r\n info.headers[\"Content-Type\"] = \"application/x-www-form-urlencoded\";\r\n info.headers[\"Authorization\"] = _application__WEBPACK_IMPORTED_MODULE_0__[\"Application\"].App.config.vtoken;\r\n info.headers[\"X-Version\"] = _App_config__WEBPACK_IMPORTED_MODULE_1__[\"SystemConfig\"].version + \"\";\r\n info.method = \"POST\";\r\n this.Request(info);\r\n };\r\n HttpUtils.SendRequest = function (client, data) {\r\n if (!data.info) {\r\n return;\r\n }\r\n var info = data.info;\r\n if (_application__WEBPACK_IMPORTED_MODULE_0__[\"Application\"].App.IsBackend) {\r\n info.success = function (body) {\r\n client.Send({ body: body, code: 0 });\r\n };\r\n info.error = function () {\r\n client.Send({ code: -1 });\r\n };\r\n HttpUtils.Request(info);\r\n }\r\n else {\r\n // content 做转发\r\n var extClient = _application__WEBPACK_IMPORTED_MODULE_0__[\"Application\"].App.Client;\r\n extClient.Send({ type: \"GM_xmlhttpRequest\", info: info });\r\n extClient.Recv(function (data) {\r \n client.Send(data);\r\n });\r\n }\r\n };\r\n return HttpUtils;\r\n}());\r\n\r\n/**\r\n * 通过源码注入js资源\r\n * @param doc\r\n * @param url\r\n * @constructor\r\n */\r\nfunction Injected(doc, source) {\r\n var temp = doc.createElement('script');\r\n temp.setAttribute('type', 'text/javascript&



超星 工具

需要 登录 后方可回复, 如果你还没有账号请 注册新账号
相关文章