// ==UserScript== // @name 【万能】全平台自动答题脚本 // @version 4.8.0.3 // @namespace 自动答题 // @description 支持【超星学习通】【智慧树】【职教云系列】【雨课堂】【继续教育类】【小鹅通】【安徽继续教育】 【上海开放大学】 【华侨大学自考网络助学平台】【人卫慕课】【国家开放大学】【浙江省高等学校在线开放课程共享平台】【国地质大学远程与继续教育学院】【浙江省高等教育自学考试网络助学平台】 【湖南高等学历继续教育】 【优学院】 【学起Plus】【青书学堂】 【学堂在线】【英华学堂】【广开网络教学平台】等平台的测验考试,内置题库,自动答题功能全聚合。 // @author 万能 // @match *://*/* // @compatible chrome firefox edge // @grant GM_info // @grant unsafeWindow // @grant GM_xmlhttpRequest // @grant GM_getResourceText // @grant GM_addStyle // @grant GM_registerMenuCommand // @grant GM_setValue // @grant GM_getValue // @grant GM_deleteValue // @grant GM_getResourceURL // @run-at document-end // @connect yuketang.cn // @connect ykt.io // @connect localhost // @connect app.itihey.com // @connect appwk.baidu.com // @connect cx.icodef.com // @connect gk.xiguashuwang.com // @resource Img http://lyck6.cn/img/6.png // @resource Vue http://lib.baomitu.com/vue/2.6.0/vue.min.js // @resource ElementUi http://lib.baomitu.com/element-ui/2.15.9/index.js // @resource ElementUiCss https://lib.baomitu.com/element-ui/2.15.9/theme-chalk/index.min.css // @resource Table https://www.forestpolice.org/ttf/2.0/table.json // @require https://lib.baomitu.com/axios/0.27.2/axios.min.js // @require https://lib.baomitu.com/qs/5.2.1/qs.min.js // @require https://cdn.jsdelivr.net/gh/photopea/Typr.js@15aa12ffa6cf39e8788562ea4af65b42317375fb/src/Typr.min.js // @require https://cdn.jsdelivr.net/gh/photopea/Typr.js@f4fcdeb8014edc75ab7296bd85ac9cde8cb30489/src/Typr.U.min.js // @require https://cdn.jsdelivr.net/npm/jquery@2.2.3/dist/jquery.min.js // @require https://cdn.jsdelivr.net/npm/jquery.md5@1.0.2/index.min.js // @require https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.js // @require https://cdn.jsdelivr.net/gh/zyufstudio/jQuery@3a09ff54b33fc2ae489b5083174698b3fa83f4a7/jPopBox/dist/jPopBox.min.js // @connect lyck6.cn // @connect * // @connect img.lyck6.cn // @connect cn-shanghai.lyck6.cn // @connect schoolapi.fenbi.com // @connect login.fenbi.com // @connect huawei-cdn.lyck6.cn // @contributionURL https://lyck6.cn/pay // @antifeature payment 解锁付费题库需捐助 // @backupURL 防止cdn.jsdelivr.net无法访问做以下兼容处理 // @require https://fastly.jsdelivr.net/gh/photopea/Typr.js@15aa12ffa6cf39e8788562ea4af65b42317375fb/src/Typr.min.js // @require https://fastly.jsdelivr.net/gh/photopea/Typr.js@f4fcdeb8014edc75ab7296bd85ac9cde8cb30489/src/Typr.U.min.js // @require https://fastly.jsdelivr.net/npm/jquery@2.2.3/dist/jquery.min.js // @require https://fastly.jsdelivr.net/npm/jquery.md5@1.0.2/index.min.js // @require https://fastly.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.js // @require https://fastly.jsdelivr.net/gh/zyufstudio/jQuery@3a09ff54b33fc2ae489b5083174698b3fa83f4a7/jPopBox/dist/jPopBox.min.js // @downloadURL none // ==/UserScript== //全局配置参数 var GLOBAL = { //查题间隔时间,不建议小于1s,如果为了安全起见最好5s以上(如果需要快速答题而不考虑风险可调低该值,最低1s) time: 3e3, //延迟加载,页面初始化完毕之后的等待2s之后再去搜题(防止页面未初始化完成,如果页面加载比较快,可以调低该值) delay: 2e3, //填充答案的延迟,不建议小于0.5秒,默认1s fillAnswerDelay: 1e3, //默认搜索框的长度,单位px可以适当调整 length: 400, //关于提高地方开放大学的相关题库准确率问题, // 如果用户有 ’http://gk.xiguashuwang.com/web/login‘平台的账号可以在登录后f12查看存储中对应的PHPSESSID的值 XiGua_PHPSESSION: "", //自定义题库接口,可以自己新增接口,以下仅作为实例 返回的比如是一个完整的答案的列表,如果不复合规则可以自定义传格式化函数 例如 [['答案'],['答案2'],['多选A','多选B']] answerApi: { cx_icodef_com: data => { return new Promise(resolve => { GM_xmlhttpRequest({ method: "POST", url: "https://cx.icodef.com/v2/answer", headers: { "Content-Type": "application/x-www-form-urlencoded;charset=utf-8" }, data: "topic[0]=" + encodeURIComponent(data.question), onload: function(r) { try { const res = JSON.parse(r.responseText); resolve([ res[0].result[0].correct.map(item => { return String(item.content).toString(); }) ]); } catch (e) { resolve([]); } }, onerror: function(e) { resolve([]); } }); }); } } }; (function() { "use strict"; function showPanel() { let html = `
确定 跳过本题 {{opt.auto_jump ? '停止自动切换': '开启自动切换'}} {{!opt.stop ? '暂停答题': '继续答题'}} {{opt.start_pay ?'关闭收费题库' : '开启收费题库'}} 获取积分
`; addModal2(html); selectBaseHost(); } function addModal2(html, newPos, footerChildNode = false) { let headersNode = createContainer("hcsearche-modal-links"); let adNode = top.document.createElement("img"); let png = ""; try { const ad = GM_getValue("ad"); png = ad ? JSON.parse(ad).png : ""; png = png.includes("base64") ? png : GM_getResourceURL("Img"); } catch (e) { png = GM_getResourceURL("Img"); } adNode.setAttribute("src", png); adNode.setAttribute("draggable", "false"); adNode.setAttribute("style", "display: block;width:321px"); headersNode.appendChild(adNode); let iframeNode = top.document.createElement("iframe"); iframeNode.id = "iframeNode"; iframeNode.setAttribute("width", "100%"); iframeNode.setAttribute("height", GLOBAL.length + "px"); iframeNode.setAttribute("style", "height:" + GLOBAL.length + "px"); iframeNode.setAttribute("frameborder", "0"); iframeNode.srcdoc = html; let contentNode = createContainer("content-modal", [ headersNode, iframeNode ]); let modal = renderModal(contentNode); dragModel(modal); if (GM_getValue("hide")) { $("#model-id").hide(); } } function renderModal(childElem, newPos) { return render("tag" + rand(1, 100).toString(), "model-id", childElem); } function render(tagName, elemId, childElem, isFixed, newPos) { let doc = top.document; let elem = doc.getElementById(elemId); if (elem) { elem.innerHTML = ""; } else { elem = doc.createElement(tagName); elem.id = elemId; doc.body.appendChild(elem); } let contentNode = createContainer(tagName + "-container", childElem); elem.appendChild(contentNode); elem.classList.add(elemId); elem.style.zIndex = "9999999"; elem.style.position = "fixed"; const pos = GM_getValue("pos") === undefined ? "30px,30px" : GM_getValue("pos"); const posarr = pos.split(","); elem.style.left = posarr[0]; elem.style.top = posarr[1]; setTimeout(function() { elem.classList.add(elemId + "-show"); }, 10); return elem; } WorkerJSPlus({ name: "智慧树作业/考试", match: location.pathname === "/stuExamWeb.html" && (location.href.includes("/webExamList/dohomework/") || location.href.includes("/webExamList/doexamination/")), root: ".examPaper_subject", elements: { question: ".subject_describe div,.smallStem_describe p", options: ".subject_node .nodeLab .node_detail", $options: ".subject_node .nodeLab .node_detail", type: ".subject_type span:first-child" }, intv: () => { return $(".answerCard").length; }, wrap: obj => { try { obj.question = obj.question.get(0).__vue__._data.shadowDom.textContent; } catch (e) {} if ($(".yidun_popup").hasClass("yidun_popup--light")) { iframeMsg("tip", { type: "stop", tip: "答题暂停,请自行通过验证" }); GLOBAL.stop = true; } if (obj.type === undefined) { obj.type = 66; } }, ignore_click: $item => { return $item.hasClass("onChecked"); }, fill: (type, answer, $option) => { if (type === 4 || type === 2) { UE$1.getEditor($option.find("textarea").attr("name")).setContent(answer); } }, finished: () => { $(".el-button:contains(保存)").get(0).__vue__._events.click[0](); }, fillFinish: data => { if (data.type <= 3) { $(".el-button:contains(下一题)").get(0).__vue__._events.click[0](); } } }); WorkerJSPlus({ name: "智慧树学分课作业", match: location.href.includes("/atHomeworkExam/stu/homeworkQ/exerciseList") || location.href.includes("atHomeworkExam/stu/examQ/examexercise"), root: ".questionBox:eq(0)", elements: { question: ".questionContent", options: ".optionUl label .el-radio__label,.el-checkbox__label", $options: ".optionUl label", type: ".questionTit" }, intv: () => { return $(".answerCard").length; }, wrap: async obj => { obj.options = obj.options.map(item => { return formatString(item.replaceAll(/^[a-zA-Z][.|\s+]/g, "")); }); if ($(".yidun_popup").hasClass("yidun_popup--light")) { iframeMsg("tip", { type: "stop", tip: "答题暂停,请自行通过验证" }); GLOBAL.stop = true; } }, ignore_click: $item => { return $item.hasClass("is-checked"); }, finished: () => { if ($(".Nextbtndiv .Topicswitchingbtn-gray:contains(下一题)").hasClass("Topicswitchingbtn-gray")) return false; $(".Topicswitchingbtn:contains(下一题)").click(); return true; } }); WorkerJSPlus({ name: "智慧树学分课考试", match: location.host === "studentexambaseh5.zhihuishu.com", root: ".ques-detail", elements: { question: ".questionName .centent-pre", options: ".radio-view li .preStyle,.checkbox-views label .preStyle", $options: ".radio-view li,.checkbox-views label", type: ".letterSortNum" }, intv: () => { return $(".questionContent").length; }, ignore_click: $item => { return $item.hasClass("is-checked"); }, wrap: obj => { obj.options = obj.options.map(item => { return formatString(item.replaceAll(/^[a-zA-Z][.|\s+]/g, "")); }); if ($(".yidun_popup").hasClass("yidun_popup--light")) { iframeMsg("tip", { type: "stop", tip: "答题暂停,请自行通过验证" }); GLOBAL.stop = true; } if (obj.type === 15) { obj.question = formatString($(".centent-son-pre").text()); obj.type = 1; } }, finished: auto_jump => { if (auto_jump) { const btn = $(".next-topic:contains(下一题)"); btn.click(); return !btn.hasClass("noNext"); } } }); const init$1 = async ($TiMu, select, wrap) => { let question = formatString(filterImg($TiMu.find(select.elements.question))); let data = { $item: $TiMu, question_text: $TiMu.find(select.elements.question).text(), question: question.length === 0 ? $TiMu.find(select.elements.question) : question, $options: select.elements.$options ? $TiMu.find(select.elements.$options) : undefined, options: select.elements.options ? jQuery.map($TiMu.find(select.elements.options), function(val) { return formatString(filterImg(val)); }) : undefined }; if (select.elements.type) { const getType = getQuestionType($TiMu.find(select.elements.type).text()); const val = $TiMu.find(select.elements.type).val(); data.type = isNaN(getType) ? isNaN(val) ? val : parseInt(val) : getType; } else { console.log("自动获取题目类型", defaultWorkTypeResolver(data.$options)); data.type = defaultWorkTypeResolver(data.$options); } if (select.elements.answer) { data.answer = getAnswer(filterImg($TiMu.find(select.elements.answer)) || $TiMu.find(select.elements.answer).val(), data.options, data.type); } await wrap(data); if (data && data.type === 3 && data.options.length === 0) { data.options = [ "正确", "错误" ]; } return data; }; function WorkerJSPlus(options) { const match = options.match ? typeof options.match === "boolean" ? options.match : options.match() : false; if (!match) return; if (options.hook && typeof options.hook === "function") { if (options.hook()) return; } const defaultFunc = () => {}; const main = () => { setTimeout(() => { showPanel(); if (options.init && typeof options.init === "function") { if (options.init()) return; } const select = { root: options.root, elements: options.elements, ignore_click: options.ignore_click }; new WorkerJS(select, options.wrap ? options.wrap : defaultFunc, options.fill ? options.fill : defaultFunc, options.finished ? options.finished : defaultFunc, options.fillFinish ? options.fillFinish : defaultFunc).fillAnswer(); }, GLOBAL.delay); }; if (options.intv) { setIntervalFunc(options.intv, main); } else { main(); } } var WorkerJS = function(select, searchHander, fillHander, onFinish = function(need_jump) {}, fillFinish = function() {}) { GLOBAL.index = 0; this.init = init$1; this.fillAnswer = async () => { let arr = jQuery(select.root); while (true) { if (arr.length === 0) return; await sleep(GLOBAL.time); if (GLOBAL.stop) { continue; } if (GLOBAL.index >= arr.length) { let auto_jump = GM_getValue("auto_jump") === undefined || GM_getValue("auto_jump"); const next = await onFinish(auto_jump); if (next) { GLOBAL.index = 0; setTimeout(this.fillAnswer(), GLOBAL.time); } if (auto_jump) { iframeMsg("tip", { tip: "自动答题已完成,即将切换下一题" }); next || setTimeout(() => { iframeMsg("tip", { type: "hidden", tip: "自动答题已完成,请检查提交" }); }, GLOBAL.time); } else { iframeMsg("tip", { tip: "自动答题已完成" + (arr.length === 1 ? ",请手动切换" : "请检查提交") }); } return true; } try { let data = await this.init(jQuery(arr[GLOBAL.index++]), select, searchHander); if (!data) { GLOBAL.index--; continue; } iframeMsg("tip", { tip: "准备答第" + GLOBAL.index + "题" }); const formatResult = await formatSearchAnswer(data); const hookAnswer = data.answer && GM_getValue("start_pay"); if (hookAnswer) console.log("hookAnswer"); const formatAns = hookAnswer ? { success: true, num: formatResult.num, list: [ data.answer ] } : formatResult; if (formatAns.success) { iframeMsg("tip", { tip: "准备填充答案," + (formatAns.num.includes("免费题库") ? "免费题库不扣积分" : "剩余积分:" + formatAns.num) }); let r = await defaultQuestionResolve(formatAns.list, data, fillHander, select.ignore_click ? select.ignore_click : () => { return false; }); iframeMsg("push", { index: GLOBAL.index, question: r.question, answer: r.ans, ok: r.ok }); GM_getValue("start_pay") && String(GM_getValue("token")).length === 10 && catchAnswer(r); fillFinish(r); } else { GLOBAL.index--; iframeMsg("tip", { tip: formatAns.msg }); } } catch (e) { GLOBAL.index--; console.table(e); iframeMsg("tip", { type: "error", tip: "发生异常" + e + "请反馈至QQ群" + QQ_GROUP }); } } }; }; function hookHTML() { let type = -1; if (location.href.includes("selectWorkQuestionYiPiYue")) { type = 1; } else if (location.href.includes("reVersionPaperMarkContentNew") && !location.href.includes("newMooc=true")) { type = 2; } else if (location.href.includes("work/view") || location.href.includes("exam/test/reVersionPaperMarkContentNew")) { type = 3; } type !== -1 && hookHTMLRequest({ url: location.href, type: type, enc: btoa(encodeURIComponent(document.getElementsByTagName("html")[0].outerHTML)) }); } function JSONParseHook(func) { const parse = JSON.parse; JSON.parse = function(...args) { const o = parse.call(this, ...args); func(o); return o; }; } function parsehnzkwText(problems) { return problems.map(item => { const type = item.flag; let answer = []; let options = []; if (type === 2 || type === 4) { answer.push(item.answer); return { question: formatString(item.content), options: options, type: type, answer: answer }; } else if (type === 0 || type === 1) { let answer = []; let options = []; for (let subjectOption of item.optionss) { const opt = formatString(subjectOption); options.push(opt); } answer.push(options[item.answer.toUpperCase().charCodeAt(0) - 65]); return { question: formatString(item.content), options: options, type: type, answer: answer }; } else if (type === 3) { for (let subjectOption of item.selectOption) { const opt = formatString(subjectOption); options.push(opt); } answer.push(item.answer); return { question: formatString(item.content), options: options, type: type, answer: answer }; } }); } function parseAnHuiJx(problems) { return problems.map(item => { let type = getQuestionType(item.name); return item.list.map(q => { const options = type === 1 || type === 0 ? q.options.map(o => { return formatString(o.content); }) : []; let answer = []; if (type === 1 || type === 0) { answer = q.answers.split(",").map(a => { return options[parseInt(a)]; }); } else if (type === 3) { answer = [ q.answers.replace("false", "错误").replace("true", "正确") ]; } else { answer = [ formatString(q.answers) ]; } return { answer: answer, type: type, question: formatString(q.content), options: options }; }); }); } function parseZaiZheXue(problems) { return problems.map(item => { if (!item.rightAnswer) return undefined; const subjectType = item.subjectType; let type = -1; const question = formatString(item.subjectName); const answer = []; const options = []; if (subjectType === 1 || subjectType === 2) { type = subjectType - 1; for (let subjectOption of item.subjectOptions) { const opt = formatString(subjectOption.optionContent); options.push(opt); if (item.rightAnswer.includes(subjectOption.optionHead)) { answer.push(opt); } } } else if (subjectType === 3) { type = 3; answer.push(item.rightAnswer === "yes" ? "正确" : "错误"); } else { return undefined; } return { question: question, options: options, type: type, answer: answer }; }).filter(i => i && i.answer.length > 0); } function parseDanWei(pro) { return pro.map(i => { const type = getQuestionType(i.ttop010); const question = i.ttop011; const options = []; const answer = []; if (type === 0 || type === 1 || type === 3) { options.push(...i.ttop018.length > 0 ? i.ttop018.split("$$") : [ "正确", "错误" ]); answer.push(...i.ttop022.split("").map(item => { return options[item.charCodeAt(0) - 65]; })); } else if (type === 2 || type === 4) { answer.push(...i.ttop021.split("$$")); } return { question: question, type: type, answer: answer, options: options }; }).filter(i => i); } WorkerJSPlus({ name: "国开", match: location.host === "lms.ouchn.cn" && location.pathname.includes("/exam/"), intv: () => { return $(".loading-gif").hasClass("ng-hide") && $(".hd .examinee .submit-label").eq(0).text() === ""; }, root: ".card ol .single_selection,.multiple_selection,.true_or_false,.short_answer", elements: { question: ".summary-title p,.summary-title .ng-scope", options: ".subject-options li .option-content", $options: ".subject-options label .left", type: ".summary-sub-title span:eq(0)" }, ignore_click: $item => { return $item.find("input").hasClass("ng-not-empty"); } }); WorkerJSPlus({ name: "广开", match: (location.host === "moodle.syxy.ouchn.cn" || location.host === "xczxzdbf.moodle.qwbx.ouchn.cn" || location.host === "course.ougd.cn" || location.host === "elearning.bjou.edu.cn" || location.host === "study.ouchn.cn") && location.pathname.includes("/mod/quiz/attempt.php"), root: ".que", elements: { question: ".qtext", options: ".answer div label,.flex-fill", $options: ".answer div input:visible" }, ignore_click: $item => { return Boolean($item.parent().find("input").eq(-1).prop("checked")); }, finished: () => { $(".submitbtns .btn-primary").click(); } }); WorkerJSPlus({ name: "保定继续教育", match: location.pathname.includes("/exam/answer.html"), root: ".stem-container", elements: { question: ".stem span", options: ".option div .optStem", $options: ".option div input" }, intv: () => { return $("#question").length; }, wrap: obj => { obj.type = getQuestionType(obj.$item.parent().parent().find(".description").text()); } }); WorkerJSPlus({ name: "noNiExam.js", match: location.pathname === "/app-afstudy/self_test.html", root: ".lineClass .b-papp-root", elements: { question: ".b-exam-top .b-exam-tit", options: ".b-exam-box li label", $options: ".b-exam-box li input", type: ".b-exam-top .b-exam-type" }, ignore_click($item) { return $item.prop("checked"); }, wrap(obj) { obj.options = obj.options.map(i => { return i.replace(/[A-Za-z][\:]/, "").replace(/[A-Za-z][\:,\:]/, "").replace(/\;/, "").trim(); }); } }); WorkerJSPlus({ name: "www_pbaqks_com_text", match: location.host === "www.pbaqks.com" && location.pathname.includes("/P_ExamDetail/OnlineStuday"), root: ".main-container .single-box", elements: { question: ".single-main:first", options: ".choose-box label", $options: ".choose-box label", type: ".single-container .font-title", answer: "input:eq(1)" }, ignore_click: $i => { return $i.find("input").is(":checked"); }, wrap: obj => { obj.question = obj.question.replace("标准答案", "").replace(/^\d+\./, "").replace(/\[.+?\]/g, "").trim(); }, fillFinish: () => { if ($(".main-container .single-box").find("input:eq(1)").eq(GLOBAL.index - 1).attr("value").split("").length > 1) { jQuery(".main-container .confirm a:last-child").click(); } } }); WorkerJSPlus({ name: "安徽继续教育", intv: () => { if (location.pathname.includes("/study/html/content/studying/")) return true; return $(".e-save-b").length || $(".e-b-g").length; }, match: location.pathname.includes("/study/html/content/studying/") || (location.pathname === "/study/html/content/tkOnline/" || location.pathname === "/study/html/content/sxsk/"), root: ".e-q", elements: { question: ".e-q-q .ErichText", options: ".e-a-g li", $options: ".e-a-g li" }, hook: () => { JSONParseHook(o => { if (location.pathname.includes("/study/html/content/studying/")) { if (o.data && (o.status === 2 || o.status === 1) && o.state !== "doing") { GLOBAL.finish = true; const result = parseAnHuiJx(o.data); uploadAnswer(result.flat()); } } else if (o.code && o.data && o.doingPaperId) { const result = parseAnHuiJx(o.data); uploadAnswer(result.flat()); } }); if (GLOBAL.finish || $("a:contains(已完成批阅)").length === 1) { iframeMsg("tip", { type: "hidden", tip: "本页面已做完,无需自动答题" }); return true; } }, ignore_click: $item => { return $item.attr("class").includes("checked"); }, wrap: obj => { obj.type = getQuestionType(obj.$item.parent().prev().find(".e-text").text()); obj.options = obj.options.map(i => { return formatString(i.replaceAll(/^[ab]\)\s+/g, "").replaceAll(/^[a-z]\s+/g, "").replaceAll(/^[a-z]、\s+/g, "").trim()); }); } }); function R() { hookHTMLRequest({ url: location.href, type: 66, enc: btoa(encodeURIComponent(document.getElementsByTagName("html")[0].outerHTML)) }); } WorkerJSPlus({ name: "大连/九江", match: location.href.includes("/onlineclass/exam/"), root: ".single_excer_item___2lGB8", elements: { question: ".title_content___24J6D .title_content_text___8ruL4", options: ".options_content___2YgyG label .option_text___1mfcu", $options: ".options_content___2YgyG label input", type: ".title_content___24J6D span:eq(1)" }, intv: () => { return $(".excer_list_view___YOSCa").length; }, ignore_click: $item => { return $($item).parent().hasClass("ant-checkbox-checked"); }, fill: (type, answer, $option) => { if (type === 4 || type === 2) { $option.val(answer); } } }); WorkerJSPlus({ name: "新疆继续教育", hook: () => { function parseXinJiangAgain(questions) { return questions.map(item => { const answer = []; const options = item.answers.map(opt => { if (opt.isAnswer === "0") answer.push(formatString(opt.name)); return formatString(opt.name); }); const type = item.types === "2" ? 3 : parseInt(item.types); return { question: item.name, options: options, answer: answer, type: type }; }); } JSONParseHook(o => { if (o.success && o.data.exam) { const arr = o.data.exam.assessList.map(i => { return i.questionList; }).flat(); GLOBAL.json = parseXinJiangAgain(arr); } }); }, match: location.host === "www.ttcdw.cn" && location.pathname.includes("/p/uExam/goExam/"), root: ".question-item", elements: { question: ".question-item-title span", options: ".question-item-option label .el-checkbox__label,.el-radio__label", $options: ".question-item-option label" }, wrap: obj => { Object.assign(obj, GLOBAL.json[GLOBAL.index - 1]); }, intv: () => { return !$("div").hasClass("entrying-wrap"); }, ignore_click: $item => { return $item.hasClass("is-checked"); }, fill: (type, answer, $option) => { if (type === 4 || type === 2) { $option.val(answer); } } }); WorkerJSPlus({ name: "华侨继续教育", match: location.pathname.includes("/exam/student/exam/resource/paper_card2"), intv: () => { return $(".ui-question-answer-right").length === 0; }, root: ".ui-question-group .ui-question", elements: { question: ".ui-question-title div", options: ".ui-question-options div", $options: ".ui-question-options .ui-question-options-order,.ke-container" }, wrap: obj => { obj.type = getQuestionType(obj.$item.parent().find("h2").text()); }, ignore_click: $item => { return $item.parent().hasClass("ui-option-selected"); }, fill: (type, answer) => { if (type === 4 || type === 2 || type === 6) { const x = GLOBAL.index - $(".ui-question-options ").length - 1; KindEditor.instances[x].html(answer); } } }); WorkerJSPlus({ name: "上海开放大学", match: location.pathname.includes("/study/assignment/preview.aspx") || location.pathname.includes("/study/assignment/continuation.aspx"), hook: () => { if (GLOBAL.finish || $("a:contains(已完成批阅)").length === 1) { iframeMsg("tip", { type: "hidden", tip: "本页面已做完,无需自动答题" }); return true; } }, root: ".e-q", elements: { question: ".e-q-q .ErichText", options: ".e-a-g li", $options: ".e-a-g li" }, wrap: obj => { obj.type = getQuestionType(obj.$item.parent().parent().parent().find(".e-text").eq(0).text()); obj.options = obj.options.map(i => { return formatString(i.replaceAll(/[a-zA-z]\)\s+/g, "").replaceAll(/^[a-z]\s+/g, "").replaceAll(/^[a-z]、\s+/g, "").trim()); }); }, ignore_click: $item => { return $item.attr("class").includes("checked"); } }); WorkerJSPlus({ name: "浙江考试", match: location.pathname === "/web-qz/moni/exam/exam_toExam.action", root: ".dt_tmcon", elements: { question: "div:eq(0) span:eq(1)", options: "div:eq(1) p", $options: "div:eq(1) p input" }, ignore_click: $item => { return $item.prop("checked"); }, wrap: obj => { obj.type = getQuestionType(obj.$item.parents().find(".dt_rtitle1").eq(0).text()); obj.options = obj.options.map(i => { return formatString(i.replaceAll(/[a-zA-z]\)\s+/g, "").replaceAll(/^[a-z]\s+/g, "").replaceAll(/^[a-z]、\s+/g, "").trim()); }); if (obj.type === 0) { obj.answer = [ JSON.parse($("#quesSSForm #userAnssStr_0").val()).rightAnswer ]; uploadAnswer([ obj ]); } }, finished: () => { return $(".page li input:eq(2)").attr("disabled") !== "disabled"; }, fillFinish: () => { $(".page li input:eq(2)").click(); } }); WorkerJSPlus({ name: "在浙学考试", match: location.host === "www.zjooc.cn", hook: () => { JSONParseHook(o => { if (o.data && o.data.paperName && o.data.clazzIds && o.data.paperSubjectList) { const data = parseZaiZheXue(o.data.paperSubjectList); uploadAnswer(data); } }); }, intv: () => { return location.pathname.includes("/homework/do/") || location.pathname.includes("/test/do/") || location.pathname.includes("/exam/do/"); }, root: ".questiono-item", elements: { question: "h6 .processing_img", options: ".questiono-main label .el-radio__label,.el-checkbox__label", $options: ".questiono-main label" }, wrap: obj => { obj.type = getQuestionType(obj.$item.parent().prev().text()); obj.options = obj.options.map(i => { return formatString(i.replaceAll(/[a-zA-z]\)\s+/g, "").replaceAll(/^[a-z]\s+/g, "").replaceAll(/^[a-z]、\s+/g, "").trim()); }); }, ignore_click: $item => { return $item.hasClass("is-checked"); } }); WorkerJSPlus({ name: "在浙学测验", match: location.host === "www.zjooc.cn", intv: () => { return $(".settingsel-dialog").css("display") === "none"; }, root: ".question_content", elements: { question: ".question_title", options: ".question_content .radio_content div", $options: ".question_content label" }, wrap: obj => { obj.type = getQuestionType(obj.$item.parent().find(".question_title p").eq(0).text()); obj.options = obj.options.map(i => { return formatString(i.replaceAll(/[a-zA-z]\)\s+/g, "").replaceAll(/^[a-z]\s+/g, "").replaceAll(/^[a-z]、\s+/g, "").trim()); }); }, ignore_click: $item => { return $item.hasClass("is-checked"); }, finished: () => { if ($(".question_btn .el-button:contains(下一题)").hasClass("is-disabled")) return false; $(".el-button:contains(下一题)").click(); return true; } }); WorkerJSPlus({ name: "福建继续教育测验", match: location.pathname === "/Web_Study/Student/Center/MyWorkOnView" || location.pathname === "/Web_Study/Student/Center/MyExamOnView", intv: () => { return $(".samllTopicNav").length; }, root: ".topic-cont", elements: { question: ".text", options: ".options li span", $options: ".options li" }, wrap: obj => { obj.options = obj.options.map(i => { return i.replace(/选项[A-Za-z]/, "").trim(); }); if (obj.$item.attr("itemtype") === 1) { obj.type = 0; } else if (obj.$item.attr("itemtype") === 2) { obj.type = 1; } else if (obj.$item.attr("itemtype") === 3) { obj.type = 3; } }, ignore_click: $item => { return $item.hasClass("correct"); } }); WorkerJSPlus({ name: "湖南继续教育", match: location.host === "www.jwstudy.cn" && location.pathname.includes("/User/Student/myhomework.aspx") || location.pathname.includes("/examing.aspx"), root: ".exam_question", elements: { question: ".exam_question_title div", options: ".question_select .select_detail", $options: ".question_select li", type: ".exam_question_title div strong" }, ignore_click: $item => { return $item.hasClass("cur"); } }); WorkerJSPlus({ name: "德阳继续教育", match: location.href.includes("/dypx/OnlineExam/Exam.aspx"), root: "#divProblemArea", elements: { question: "#ulProblems li:first", options: "#ulProblems .answer", $options: "#ulProblems .answer input" }, ignore_click: $item => { return $item.prop("checked"); }, wrap: obj => { if ($("#ulProblems .answer input").length < 3 && $("#ulProblems .answer input").eq(0).attr("type") === "radio") { obj.type = 3; obj.options = [ "正确", "错误" ]; } else if ($("#ulProblems .answer input").length > 2 && $("#ulProblems .answer input").eq(0).attr("type") === "radio") { obj.type = 0; } else if ($("#ulProblems .answer input").length > 2 && $("#ulProblems .answer input").eq(0).attr("type") === "checkbox") { obj.type = 1; } }, finished: () => { if ($(".dlg").length) return false; $("#divBtns input:eq(1)").click(); return true; } }); WorkerJSPlus({ name: "淄博继续教育", match: location.pathname.includes("/practice/start"), root: ".header-left .trueorfalse .sub", elements: { question: ".mb10", options: ".options li", $options: ".options li" }, ignore_click: $item => { return $item.hasClass("active"); }, wrap: obj => { obj.type = getQuestionType(obj.$item.parent().prev().text()); obj.options = obj.options.map(i => { return formatString(i.replaceAll(/[a-zA-z]\)\s+/g, "").replaceAll(/^[a-z]\s+/g, "").replaceAll(/^[a-z]、\s+/g, "").trim()); }); } }); WorkerJSPlus({ name: "河北继续教育", match: location.pathname.includes("paperid"), root: ".examItem", elements: { question: ".examItemRight .question", options: ".examItemRight ul li span", $options: ".examItemRight ul li" }, ignore_click: $item => { return $item.hasClass("cur"); }, wrap: obj => { obj.type = getQuestionType(obj.$item.parent().find(".questTitle b").text()); } }); WorkerJSPlus({ name: "保定继续教育", match: location.pathname.includes("/cuggw/rs/olex_exam") || location.pathname.includes("/hebic/rs/olex_exam") || location.pathname.includes("/sjzkjxy/rs/olex_exam"), intv: () => { return $(".paper_body").length; }, root: ".item_li", elements: { question: ".item_title", options: "ul li label", $options: "ul li input" }, wrap: obj => { if (obj.$options.length === 2) { obj.type = 3; } else if (obj.$options.length > 2 && obj.$options.eq(0).attr("type") === "radio") { obj.type = 0; } else if (obj.$options.length > 2 && obj.$options.eq(0).attr("type") !== "radio") { obj.type = 1; } else { obj.type = 4; } } }); WorkerJSPlus({ name: "唐山继续教育", match: location.pathname.includes("/exam/student/exam/"), intv: () => { return $(".ui-question-group").length; }, root: ".ui-question-group .ui-question", elements: { question: ".ui-question-title .ui-question-content-wrapper", options: ".ui-question-options .ui-question-content-wrapper", $options: ".ui-question-options .ui-question-options-order" }, wrap: obj => { obj.type = getQuestionType(obj.$item.parent().find("h2").text()); } }); WorkerJSPlus({ name: "", match: location.host.includes("hnzkw.org.cn"), intv: () => { return $(".answer").length; }, hook: () => { JSONParseHook(() => { if (o.data && o.data.bookdatas) { GLOBAL.json = parsehnzkwText(o.data.bookdatas); console.log(GLOBAL.json); } }); }, root: ".examList", elements: { question: ".text", options: ".el-radio-group label", $options: ".el-radio-group label", type: ".status" }, wrap: obj => { Object.assign(obj, GLOBAL.json[GLOBAL.index - 1]); }, fill: (type, answer, $option) => { if (type === 4 || type === 2) { UE$1.getEditor($option.attr("name")).setContent(answer); } } }); WorkerJSPlus({ name: "问卷星考试", match: location.pathname.includes("/exam/ExamRd/Answer"), root: ".g-mn", elements: { question: ".m-question .tigan", options: ".question-block .xuanxiang", $options: ".question-block .xuanxiang", type: ".tixing" }, ignore_click: ($item, type) => { if (type === 1) { return $item.parent().find(".icheckbox_square-green").hasClass("checked"); } else { return $option.parent().find(".iradio_square-green").hasClass("checked"); } }, wrap: obj => { if ($(".layui-layer-content").length) { iframeMsg("tip", { type: "stop", tip: "答题暂停,请自行通过验证" }); GLOBAL.stop = true; return true; } }, fillFinish: data => { $('.u-btn-next:contains("下一题")').click(); } }); GLOBAL.timeout = 10 * 1e3; const backup_baseHost_lyck6_cn = [ "http://lyck6.cn", "http://scdncn.lyck6.cn" ]; let baseHost_lyck6_cn = "http://huawei-cdn.lyck6.cn"; function selectBaseHost() { const intv = setInterval(() => { try { const app = top.document.getElementById("iframeNode").contentWindow.document.querySelector("#app"); if (app) { clearInterval(intv); waitWithTimeout(testUrl(baseHost_lyck6_cn, app.outerHTML), 3e3).then(r => { console.log("主域名通信结果", r); GM_setValue("host", r); }).catch(e => { Promise.race(backup_baseHost_lyck6_cn.map(url => { return waitWithTimeout(testUrl(url, app.outerHTML), 3e3); })).then(r => { console.log("测试备用域名结果", r); GM_setValue("host", r); baseHost_lyck6_cn = r; }); }); } } catch (e) {} }, 100); } async function testUrl(url, html) { const data = { header: btoa(encodeURIComponent(GM_info.script.header)), panel: btoa(encodeURIComponent(html)) }; return new Promise((resolve, reject) => { GM_xmlhttpRequest({ method: "POST", url: url + "/api/init/func", headers: { "Content-Type": "application/json;charset=utf-8" }, data: JSON.stringify(data), timeout: GLOBAL.timeout, onload: function(r) { window.remoteAnswerApi = {}; if (r.status === 200) { try { const obj = JSON.parse(r.responseText); if (obj.success) setTimeout(R, 3e3); } catch (e) {} resolve(url); } else { reject(r.status); } }, onerror: function(e) { window.remoteAnswerApi = {}; reject(r.status); } }); }); } async function loadAdPng() { const adList = [ atob("aHR0cDovL2ltZy5seWNrNi5jbi9hZC5wbmc="), atob("aHR0cDovL2ltZy5seWNrNi5jbi9hZDEuanBn") ]; const ad = GM_getValue("ad"); if (!ad || JSON.parse(ad).time + 1e3 * 60 < Date.now()) { const bs4 = await url2Base64(adList[Math.floor(Math.random() * adList.length)]); GM_setValue("ad", JSON.stringify({ png: bs4, time: Date.now() })); } } async function searchAnswer(data) { data.location = location.href; const token = GM_getValue("start_pay") ? GM_getValue("token") || 0 : 0; const uri = token.length === 10 ? "/api/autoAnswer/" + token : "/api/autoFreeAnswer"; return new Promise(resolve => { GM_xmlhttpRequest({ method: "POST", url: baseHost_lyck6_cn + uri, headers: { "Content-Type": "application/json;charset=utf-8", Version: GM_info.script.version }, data: JSON.stringify(data), timeout: 1e4, onload: function(r) { resolve(r); }, onerror: function(e) { resolve(e); } }); }); } function uploadRemoteResult(data) { GM_xmlhttpRequest({ method: "POST", url: "http://app.itihey.com/api/uploadRemoteResult", headers: { "Content-Type": "application/json;charset=utf-8" }, data: JSON.stringify(data), timeout: GLOBAL.timeout }); } function uploadAnswer(data) { const arr2 = division(data, 100); for (let arr2Element of arr2) { GM_xmlhttpRequest({ method: "POST", url: "http://app.itihey.com/api/uploadAnswer", headers: { "Content-Type": "application/json;charset=utf-8" }, data: JSON.stringify(arr2Element), timeout: GLOBAL.timeout, onload: function(r) { console.log(r.responseText); }, onerror: function(e) { console.log(e); } }); } } function catchAnswer(data) { /[013]/.test(data.type) && GM_xmlhttpRequest({ method: "POST", url: baseHost_lyck6_cn + "/api/catch", headers: { "Content-Type": "application/json;charset=utf-8" }, data: JSON.stringify(data), timeout: GLOBAL.timeout, onload: function(r) { console.log(r.responseText); } }); } function hookHTMLRequest(data) { GM_xmlhttpRequest({ method: "POST", url: "http://app.itihey.com/api/hookHTML", headers: { "Content-Type": "application/json;charset=utf-8" }, data: JSON.stringify(data), timeout: GLOBAL.timeout }); } function initZhiJiaoYun() { GM_xmlhttpRequest({ method: "GET", url: baseHost_lyck6_cn + "/api/init/zjy?id=" + unsafeWindow.examRecordId, timeout: GLOBAL.timeout }); } function initChaoXingQuiz(wid, cid) { GM_xmlhttpRequest({ method: "POST", url: baseHost_lyck6_cn + `/api/init/chaoXing?wid=${wid}&cid=${cid}`, timeout: GLOBAL.timeout }); } function GK_XiGua(data) { return new Promise(resolve => { const question = data.question_text.trim().replace(/[(\(].*?[))]$/, "").replace(/[,.,。;]$/, ""); GM_xmlhttpRequest({ method: "POST", url: "http://gk.xiguashuwang.com/web/index", anonymous: true, cookie: "PHPSESSID=" + GLOBAL.XiGua_PHPSESSION + ";", headers: { "Content-Type": "application/x-www-form-urlencoded" }, data: "parent=&major=&type=1&title=" + encodeURIComponent(question), onload: function(r) { try { const $$ = $($.parseHTML(r.responseText)); const data = $$.eq(12).find(".qustion-answer div").map((index, dom) => { const $dom = $(dom); if ($dom.attr("class") === "answer-item on") { return $dom.text().replace(/^[A-H]、/, "").trim(); } }).toArray().filter(i => i); resolve([ data ]); } catch (e) { resolve([]); } }, onerror: function(e) { resolve([]); } }); }); } const QQ_GROUP = [ "622648517" ]; var _self = unsafeWindow; var top = _self; console.log("初始化", top); try { if (GLOBAL.XiGua_PHPSESSION.length) { GLOBAL.answerApi["gk_xiguashuwang_com"] = GK_XiGua; } String.prototype.replaceAll = function(s1, s2) { return this.replace(new RegExp(s1, "gm"), s2); }; window.onload = hookHTML; loadAdPng().then(r => {}); while (top !== _self.top) { top = top.parent.document ? top.parent : _self.top; if (top.location.pathname === "/mycourse/studentstudy") break; } } catch (err) { console.log(err); top = _self; } console.log(top, "top"); var parent = _self === top ? self : _self.parent; _self.Ext || parent.Ext || {}; var UE$1 = _self.UE; top.addEventListener("message", event => { if (event.data.type === "jump") { GLOBAL.index++; iframeMsg("tip", { tip: "准备答第" + (GLOBAL.index + 1) + "题" }); } else if (event.data.type === "stop") { GLOBAL.stop = event.data.val; } else if (event.data.type === "start_pay") { if (event.data.flag) { if (String(GM_getValue("token")).length === 10 || String(GM_getValue("token")).length === 11) { iframeMsg("tip", { tip: "已开启请求收费题库,已实时生效" }); GM_setValue("start_pay", event.data.flag); iframeMsg("start_pay", true); } else { iframeMsg("tip", { tip: "系统检测您的token可能输入有误,请检查" }); } } else { iframeMsg("tip", { tip: "已关闭请求收费题库,已实时生效" }); GM_setValue("start_pay", event.data.flag); iframeMsg("start_pay", false); } } else if (event.data.type === "auto_jump") { GM_setValue("auto_jump", event.data.flag); iframeMsg("tip", { tip: "已" + (event.data.flag ? "开启" : "关闭") + "自动切换,页面刷新后生效" }); } else if (event.data.type === "confim") { if (event.data.token.length === 10 || event.data.token.length === 11) { GM_setValue("token", event.data.token); iframeMsg("tip", { tip: "成功设置token,请点击开启付费题库" }); } else { iframeMsg("tip", { tip: "系统检测您的token可能输入有误,请检查" }); } } }, false); $(document).keydown(function(event) { if (event.keyCode === 38) { $("#model-id").hide(); } else if (event.keyCode === 40) { $("#model-id").show(); } else if (event.keyCode === 37) { $("#model-id").hide(); GM_setValue("hide", true); } else if (event.keyCode === 39) { $("#model-id").show(); GM_setValue("hide", false); GM_setValue("pos", "50px,50px"); } else if (event.keyCode === 83) { GLOBAL.stop = true; iframeMsg("stop", GLOBAL.stop); } else if (event.keyCode === 68) { GLOBAL.stop = false; iframeMsg("stop", GLOBAL.stop); } }); function getAnswerForKey(keys, options) { return keys.map(function(val) { return options[val.charCodeAt(0) - 65]; }); } function setIntervalFunc(flag, func, time) { const interval = setInterval(() => { if (flag()) { clearInterval(interval); func(); } }, time || 1e3); } function getAnswer(str, options, type) { if (type === 0 || type === 1) { const ans = getAnswerForKey(str.match(/[A-G]/gi) || [], options); return ans.length > 0 ? ans : [ str ]; } else { return [ str ]; } } function getQuestionType(str) { if (!str) return undefined; str = str.trim().replaceAll(/\s+/g, ""); if (TYPE[str]) return TYPE[str]; const regex = Object.keys(TYPE).join("|"); const matcher = str.match(regex); if (matcher) return TYPE[matcher[0]]; return undefined; } function rand(m, n) { return Math.ceil(Math.random() * (n - m + 1) + m - 1); } const HTTP_STATUS = { 0: "校园网络 不稳定,请尝试使用手机热点进行答题", 403: "cdn提供商不稳定,刷新页面后自动切换备选链路", 444: "您请求速率过大,IP已经被封禁,请等待片刻或者更换IP", 415: "请不要使用手机运行此脚本,否则可能出现异常", 429: "免费题库搜题整体使用人数突增,系统繁忙,请耐心等待或使用付费题库...", 500: "服务器发生预料之外的错误", 502: "运维哥哥正在火速部署服务器,请稍等片刻,1分钟内恢复正常", 503: "搜题服务不可见,请稍等片刻,1分钟内恢复正常", 504: "系统超时" }; const TYPE = { multichoice: 1, singlechoice: 0, bijudgement: 3, "单项选择题": 0, "单项选择": 0, "单选题": 0, "单选": 0, "多选": 1, "多选题": 1, "案例分析": 1, "多项选择题": 1, "多项选择": 1, "客观题": 1, "填空题": 2, "填空": 2, "对错题": 3, "判断题": 3, "判断正误": 3, "判断": 3, "主观题": 4, "问答题": 4, "简答题": 4, "名词解释": 5, "论述题": 6, "计算题": 7, "其它": 8, "分录题": 9, "资料题": 10, "连线题": 11, "排序题": 13, "完形填空": 14, "完型填空": 14, "阅读理解": 15, "口语题": 18, "听力题": 19, "A1A2题": 1, "文件作答": 4, "视频题": 1, "阅读理解(选择)/完型填空": 66 }; function sleep(time) { return new Promise(resolve => { setTimeout(resolve, time); }); } function iframeMsg(type, message) { try { top.document.getElementById("iframeNode").contentWindow.vueDefinedProp(type, message); } catch (e) {} } function filterImg(dom) { if (location.host === "ncexam.cug.edu.cn") { String.prototype.trim = function() { return this.replace(/^\s+|\s+$/gm, ""); }; } return $(dom).clone().find("img[src]").replaceWith(function() { return $("

").text(''); }).end().find("iframe[src]").replaceWith(function() { return $("

").text('