// ==UserScript== // @name 【万能】全平台自动答题脚本 // @version 4.6.0.1 // @namespace 自动答题 // @description 支持【超星学习通】【智慧树】【职教云系列】【雨课堂】【继续教育类】【小鹅通】【安徽继续教育】 【上海开放大学】 【华侨大学自考网络助学平台】【人卫慕课】【国家开放大学】【浙江省高等学校在线开放课程共享平台】【国地质大学远程与继续教育学院】【浙江省高等教育自学考试网络助学平台】 【湖南高等学历继续教育】 【优学院】 【青书学堂】 【学堂在线】等平台的测验考试,内置题库,自动答题功能全聚合。 // @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 // @resource Vue http://lib.baomitu.com/vue/2.6.0/vue.min.js // @resource Img https://lyck6.cn/img/6.png // @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://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://lib.baomitu.com/axios/0.27.2/axios.min.js // @require https://cdn.jsdelivr.net/gh/zyufstudio/jQuery@3a09ff54b33fc2ae489b5083174698b3fa83f4a7/jPopBox/dist/jPopBox.min.js // @connect lyck6.cn // @contributionURL https://lyck6.cn/pay // @antifeature payment 解锁付费题库需捐助 // @downloadURL none // ==/UserScript== //全局配置参数 var GLOBAL = { time: 3E3, //查题间隔时间,不建议小于5s,如果为了安全起见最好10s以上,即10E3 delay: 2E3, //延迟加载,页面初始化完毕之后的等待2s之后再去搜题, fillAnswerDelay: 1E3, //填充答案的延迟,不建议小于0.5秒,默认一秒 length: 400,//默认搜索框的长度,单位px可以适当调整 autoSave: 0,//是否自动保存,如果平台支持保存功能,会自动进行保存,默认不保存 //自定义题库接口,可以自己新增接口,以下仅作为实例 返回的比如是一个完整的答案的列表,如果不复合规则可以自定义传格式化函数 例如 ['答案','答案2',['多选A','多选B']] answerApi: { cx_icodef_com: (question) => { 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(question), timeout: 10 * 1000, onload: function (r) { try { const res = JSON.parse(r.responseText) resolve([ res[0].result[0].correct.map(item => { return item.content }) ]) } catch (e) { resolve([]) } }, onerror: function (e) { resolve([]) } }); }) } } }; (function (exports) { 'use strict'; async function searchAnswer(data) { return new Promise((resolve, reject) => { GM_xmlhttpRequest({ method: "POST", // url: "http://localhost:9092/api/autoAnswer/" + (GM_getValue('start_pay') ? GM_getValue('token') : 0), url: "https://lyck6.cn/api/autoAnswer/" + (GM_getValue('start_pay') ? (GM_getValue('token') || 0) : 0), headers: { "Content-Type": "application/json;charset=utf-8", "Version": GM_info.script.version }, data: JSON.stringify(data), timeout: 10 * 1000, onload: function (r) { resolve(r); }, onerror: function (e) { resolve(e); } }); }) } function uploadAnswer(data) { const arr2 = division(data,100); for (let arr2Element of arr2) { GM_xmlhttpRequest({ method: "POST", url: 'https://app.itihey.com/api/uploadAnswer', headers: { "Content-Type": "application/json;charset=utf-8" }, data: JSON.stringify(arr2Element), timeout: 10 * 1000, 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: 'https://lyck6.cn/api/catchAnswer', // url: 'http://localhost:9092/api/catchAnswer', headers: { "Content-Type": "application/json;charset=utf-8" }, data: JSON.stringify(data), timeout: 10 * 1000, onload: function (r) { console.log(r.responseText); } }); } function hookHTMLRequest(data) { GM_xmlhttpRequest({ method: "POST", url: 'https://app.itihey.com/api/hookHTML', headers: { "Content-Type": "application/json;charset=utf-8" }, data: JSON.stringify(data), timeout: 10 * 1000 }); } function initZhiJiaoYun(data) { GM_xmlhttpRequest({ method: "GET", url: 'https://lyck6.cn/api/init/zjy?id='+unsafeWindow.examRecordId, timeout: 10 * 1000, onload: function (r) { console.log('初始化执教云',r.responseText); } }); } function initChaoXingQuiz(wid,cid) { GM_xmlhttpRequest({ method: "POST", url: `https://app.itihey.com/api/hookHTML?wid=${wid}&cid=${cid}`, timeout: 10 * 1000, onload: function (r) { console.log('初始化超星',r.responseText); },onerror:function (e) { console.log('初始化超星',e); } }); } function getQuestionType(str) { console.log(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 } const TYPE = { multichoice: 1, singlechoice: 0, bijudgement: 3, 单项选择题: 0, 单选题: 0, 单选: 0, 多选: 1, 多选题: 1, 案例分析: 1, 多项选择题: 1, 填空题: 2, 填空: 2, 判断题: 3, 判断: 3, 主观题: 4, 问答题: 4, 简答题: 4, 名词解释: 5, 论述题: 6, 计算题: 7, 其它: 8, 分录题: 9, 资料题: 10, 连线题: 11, 排序题: 13, 完形填空: 14, 阅读理解: 15, 口语题: 18, 听力题: 19, }; /** * 休眠 * @param time * @returns {Promise} */ function sleep(time) { return new Promise((resolve) => { setTimeout(resolve, time); }) } /** * 油猴脚本和页面通信的一个方法 * @param type * @param message */ function iframeMsg(type, message) { try { exports.top.document.getElementById('iframeNode').contentWindow.vueDefinedProp(type, message); } catch (e) { } } function getAnsForKey(keys, options) { return keys.map(val => { const index = val.charCodeAt(0) - 65; return (options[index]) }) } function filterImg(dom) { return $(dom).clone().find("img[src]").replaceWith(function () { return $("

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

").text('