智慧树知到网课助手|视频挂机考试答题|全网聚合题库每日自动更新适用于几乎所有专业科目|完全免费永久使用

【🥇操作简单】智慧树知到MOOC自动挂机,无需配置安装即可使用。【🔊功能齐全】支持视频自动完成;章节测验自动答题,屏蔽弹窗题目,支持自动切换任务点、自动登录(不可用),视频自动倍速播放、线路选择、默认静音等等。【📔独家题库】独家丰富试题库,精准识别,答案全对。【✨功能扩展】解除各类功能限制,设置挂机阅读时长,开放其他自定义参数等。

  1. // ==UserScript==
  2. // @name 智慧树知到网课助手|视频挂机考试答题|全网聚合题库每日自动更新适用于几乎所有专业科目|完全免费永久使用
  3. // @namespace Muketool
  4. // @version 1.0.7
  5. // @description 【🥇操作简单】智慧树知到MOOC自动挂机,无需配置安装即可使用。【🔊功能齐全】支持视频自动完成;章节测验自动答题,屏蔽弹窗题目,支持自动切换任务点、自动登录(不可用),视频自动倍速播放、线路选择、默认静音等等。【📔独家题库】独家丰富试题库,精准识别,答案全对。【✨功能扩展】解除各类功能限制,设置挂机阅读时长,开放其他自定义参数等。
  6. // @author Muketool
  7. // @match *://*.zhihuishu.com/*
  8. // @connect api.muketool.com
  9. // @connect api2.muketool.com
  10. // @run-at document-end
  11. // @grant unsafeWindow
  12. // @grant GM_xmlhttpRequest
  13. // @grant GM_setClipboard
  14. // @grant GM_setValue
  15. // @grant GM_getValue
  16. // @license MIT
  17. // @supportURL https://docs.muketool.com
  18. // @homepage https://www.muketool.com
  19. // ==/UserScript==
  20.  
  21. // 设置修改后,需要刷新或重新打开网课页面才会生效
  22. var setting = {
  23.  
  24. //这里设置脚本所使用的题库接口。默认使用Muketool团队题库,您也可以自行替换为其他题库服务器。
  25. //Muketool团队默认提供两个题库接口:“http://api.muketool.com/”(默认使用该接口)和“http://api2.muketool.com/”,
  26. //二个题库试题数据一样,区别在于前者使用加速线路,响应更快但是易受攻击;后者采用国外高防线路速度略慢但无视网络攻击。如果您发现其中一个题库失联,可以尝试切换为另一个。
  27. tiku: 'http://api.muketool.com/'
  28.  
  29. // 5E3 == 5000,科学记数法,表示毫秒数
  30. ,time: 8E3 // 默认响应速度为5秒,不建议小于3秒
  31.  
  32. // 1代表开启,0代表关闭
  33. ,video: 1 // 视频支持课程、见面课,默认开启
  34. ,work: 1 // 自动答题功能,支持章测试、考试,高准确率,默认开启
  35. ,jump: 1 // 自动切换视频,支持课程、见面课,默认开启
  36.  
  37. // 仅开启video时,修改此处才会生效
  38. ,line: '流畅' // 视频播放的默认线路,可选参数:['高清', '流畅', '校内'],默认'流畅'
  39. ,vol: '0' // 默认音量的百分数,设定范围:[0,100],'0'为静音,默认'0'
  40. ,speed: '1.5' // 进度统计速率,高倍率可以快速完成任务点,设定范围:(0,+∞),默认'1.5'倍
  41. // 上方参数支持在页面改动,下方参数仅支持代码处修改
  42. ,que: 1 // 屏蔽视频时间点对应的节试题,取消屏蔽则自动切换为模拟点击关闭弹题,默认开启
  43. ,danmu: 0 // 见面课弹幕,关闭后在网页中无法手动开启,默认关闭
  44. ,habit: '0' // 限制视频挂机时长,单位是分钟,如需挂机习惯分,可以修改参数为'30',默认不限制
  45.  
  46. // 仅开启work时,修改此处才会生效
  47. ,none: 0 // 无匹配答案时执行默认操作,默认关闭
  48. ,hide: 0 // 不加载答案搜索提示框,键盘↑和↓可以临时移除和加载,默认关闭
  49.  
  50. , script: 'v1zhs'
  51. , version: '1.0.7'
  52.  
  53. },
  54. _self = unsafeWindow,
  55. url = location.pathname,
  56. $ = _self.jQuery,
  57. xhr = _self.XMLHttpRequest;
  58.  
  59. setting.notice = '公告栏';
  60. GM_xmlhttpRequest({
  61. method: 'GET',
  62. url: setting.tiku + 'notice?script=' + setting.type + '&version=' + setting.version,
  63. timeout: setting.time,
  64. onload: function (xhr) {
  65. if (xhr.status == 200) {
  66. var obj = $.parseJSON(xhr.responseText) || {};
  67. setting.notice = obj.injection;
  68. document.querySelector('#cx-notice').innerHTML = setting.notice;
  69. }
  70. },
  71. ontimeout: function () {
  72. setting.loop && setting.div.children('div:eq(0)').html(setting.over + '服务器超时,正在重试...');
  73. }
  74. });
  75.  
  76. String.prototype.toCDB = function() {
  77. return this.replace(/\s/g, '').replace(/[\uff01-\uff5e]/g, function(str) {
  78. return String.fromCharCode(str.charCodeAt(0) - 65248);
  79. }).replace(/[“”]/g, '"').replace(/[‘’]/g, "'").replace(/。/g, '.');
  80. };
  81.  
  82. // setting.time += Math.ceil(setting.time * Math.random()) - setting.time / 2;
  83. setting.queue = setting.curs = [];
  84.  
  85. if (!$) {
  86. } else if (url.match('/videoList')) {
  87. $.tmDialog.alert({content: '2.X版本已取消支持旧版界面', title: '智慧树网课助手提示'});
  88. } else if (url == '/videoStudy.html') {
  89. setting.habit *= 6E4;
  90. setting.video && hookVideo(_self.vjsComponent, 1);
  91. setting.jump && setInterval(checkToNext, setting.time);
  92. } else if (url == '/portals_h5/2clearning.html') {
  93. setting.video && hookVideo(_self.vjsComponent, 2);
  94. setting.jump && setInterval(checkToNext, setting.time);
  95. } else if (url == '/live/vod_room.html') {
  96. setting.video && hookVideo(_self.vjsComponent);
  97. setting.jump && setInterval(checkToNext, setting.time, 1);
  98. } else if (location.hostname.match('examh5')) {
  99. setTimeout(relieveLimit, 100, document);
  100. if (location.hash.match(/dohomework|doexamination/) && setting.work) beforeFind();
  101. $(window).on('hashchange', function() {
  102. setting.work && location.reload();
  103. });
  104. } else if (url.match('/sourceLearning')) {
  105. setting.video && hookVideo(_self.vjsComponent, 3);
  106. setting.jump && setInterval(checkToNext, setting.time, $('.source-file-item'));
  107. } else if (url == '/shareCourse/questionDetailPage') {
  108. setTimeout(relieveLimit, 100, document);
  109. $('textarea[oncut]').each(function() {
  110. setTimeout(relieveLimit, 100, this);
  111. });
  112. if($("#myAnswerInfo_div2 .option-zan").attr("islike") == 0){
  113. $("#myAnswerInfo_div2 .option-zan").click();
  114. }
  115. } else if (url.match('exerciseList') && setting.work) {
  116. _self.XMLHttpRequest = hookHiexam;
  117. setInterval(function() {
  118. $(setting.queue.shift()).parent().click();
  119. }, 1E3);
  120. setting.jump && setInterval(function() {
  121. // var $li = setting.queue.length ? $() : $('.jobclassallnumber-div li');
  122. // $li.slice($li.index($('.greenbordercur')) + 1).not('.greenbgcur').eq(0).click();
  123. setting.queue.length || $('.Topicswitchingbtn:contains(下一题)').click();
  124. }, setting.time);
  125. }
  126.  
  127. function hookVideo(Hooks, tip) {
  128. // _self.PlayerUtil.debugMode = true;
  129. _self.vjsComponent = function() {
  130. var config = arguments[0],
  131. options = config.options,
  132. line = $.map(options.sourceSrc.lines, function(value) {
  133. return value.lineName.replace('标准', '高清');
  134. }),
  135. vol = setting.vol > 100 ? 100 : setting.vol,
  136. rate = tip == 3 ? [1, 1.25, 1.5, 2, 2.5, 3] : [1, 1.25, 1.5];
  137. vol = Math.round(vol) / 100;
  138. options.volume = vol > 0 ? vol : 0;
  139. options.autostart = true;
  140. setting.speed = setting.speed > 0 ? +setting.speed : 1;
  141. options.rate = $.inArray(setting.speed, rate) < 0 ? options.rate : setting.speed;
  142. tip && config.callback.playbackRate(setting.speed);
  143. options.chooseLine = $.inArray(setting.line, line) + 1 || options.chooseLine + 1;
  144. options.src = options.sourceSrc.lines[--options.chooseLine].lineUrl || options.src;
  145. if (!setting.danmu) {
  146. config.defOptions.control.danmuBtn = false;
  147. delete options.control.danmuBtn;
  148. }
  149. Hooks.apply(this, arguments);
  150. config.player.on('loadstart', function() {
  151. this.loop(true);
  152. this.play();
  153. $('.speedBox span').text('X ' + setting.speed);
  154. });
  155. };
  156. $(document).on('click', '.definiLines b', function() {
  157. setting.line = ({xiaonei: '校内', line1gq: '高清', line1bq: '流畅'})[this.classList[0]];
  158. }).on('mouseup click', function() {
  159. setting.vol = _self.PlayerStarter.playerArray[0].player.cache_.volume * 100;
  160. }).on('click', '.speedList div', function() {
  161. setting.speed = $(this).attr('rate');
  162. });
  163. if (tip != 1) return;
  164. setting.tip = setting.habit && setInterval(totalTime, setting.time);
  165. setInterval(doTest, 1E3);
  166. _self.XMLHttpRequest = setting.que ? function() {
  167. var ajax = new xhr(),
  168. open = ajax.open;
  169. ajax.open = function(method, url) {
  170. if (url.match('/loadVideoPointerInfo')) method = 'OPTIONS';
  171. return open.apply(this, arguments);
  172. };
  173. return ajax;
  174. } : xhr;
  175. }
  176.  
  177. function totalTime() {
  178. var player = _self.PlayerStarter.playerArray[0].player;
  179. setting.habit -= player.paused() ? 0 : setting.time;
  180. if (setting.habit >= 0) return;
  181. clearInterval(setting.tip);
  182. player.pause();
  183. $.getScript('//cdn.jsdelivr.net/gh/sentsin/layer/dist/layer.js', function() {
  184. _self.layer.open({content: '已达到挂机限制时间', title: 'Muketool智慧树网课助手提示', end: function() {
  185. setting.habit = 0;
  186. }});
  187. });
  188. }
  189.  
  190. function checkToNext(tip) {
  191. if (setting.habit < 0) return;
  192. var $tip = $('.video, .lessonItem');
  193. if ($('.current_play .time_icofinish').length) {
  194. $tip.slice($tip.index($('.current_play')) + 1).not(':has(.time_icofinish)').eq(0).click();
  195. } else if ($('.lessonItemActive .finish').length) {
  196. // _self.PlayerStarter.playerArray[0].callback.playerNext();
  197. $tip.slice($tip.index($('.lessonItemActive')) + 1).not(':has(.finish)').eq(0).click();
  198. } else if (tip == 1) {
  199. $('.current_player:contains("100%") + li').click();
  200. // $('.finish_tishi').hasClass('disNo') || console.log('签到已完成');
  201. } else if ($('.settleOn .finish').length) {
  202. tip.slice(tip.index($('.settleOn')) + 1).not(':has(.finish)').eq(0).find('.file-name').click();
  203. }
  204. }
  205.  
  206. function doTest() {
  207. if (!$('.dialog-test').length) {
  208. } else if (setting.queue.length) {
  209. $(setting.queue.shift()).parent().click();
  210. } else if (!$('.answer').length) {
  211. $('.topic-item').eq(0).click();
  212. } else if (!$('.right').length) {
  213. var tip = $('.answer span').text().match(/[A-Z]/g) || [];
  214. if (tip.length == 1) return $('.topic-option-item:contains(' + tip[0] + ')').click();
  215. $('.topic-option-item').each(function() {
  216. $.inArray($(this).text().slice(0, 1), tip) < 0 == $(this).hasClass('active') && setting.queue.push(this);
  217. });
  218. } else if ($('.btn-next:enabled').length) {
  219. $('.btn-next:enabled').click();
  220. } else {
  221. $('.dialog-test .btn').click();
  222. _self.PlayerStarter.playerArray[0].player.play();
  223. }
  224. }
  225.  
  226. function relieveLimit(doc) {
  227. if (!doc.oncut && !doc.onselectstart) return setTimeout(relieveLimit, 100, doc);
  228. doc.oncontextmenu = doc.onpaste = doc.oncopy = doc.oncut = doc.onselectstart = null;
  229. }
  230.  
  231. function beforeFind() {
  232. _self.XMLHttpRequest = function() {
  233. var ajax = new xhr();
  234. ajax.onload = function(e) {
  235. if (this.status != 200 || !this.responseURL.match(/doHomework|doExam/)) return;
  236. var obj = JSON.parse(this.responseText);
  237. collectData(obj.rt.examBase);
  238. };
  239. return ajax;
  240. };
  241. setting.div = $(
  242. '<div style="border: 2px dashed #377DFF; width: 330px; position: fixed; top: 0; left: 0; z-index: 99999; background-color: #EBF2FF; overflow-x: auto;">' +
  243. '<span style="font-size: medium;"></span>' +
  244. '<div style="font-size: medium;">正在搜索答案...</div>' +
  245. '<div style="border-top: 1px solid #000;margin: 2px;overflow: hidden;font-weight:800;">MukeTool 智慧树网课助手 官网:http://muketool.com</div>' +
  246. '<div id="cx-notice" style="border-top: 1px solid #000;border-bottom: 1px solid #000;margin: 4px 0px;overflow: hidden;">' + setting.notice + '</div>' +
  247.  
  248. '<button style="margin-right: 10px;">暂停答题</button>' +
  249. '<button style="margin-right: 10px;">重新查询</button>' +
  250. '<button style="margin-right: 10px;">折叠面板</button>' +
  251. '<button style="display: none;">未作答题目</button>' +
  252. '<form style="margin: 2px 0;">' +
  253. '<label style="font-weight: bold; color: red;">自定义答题范围:</label>' +
  254. '<input name="num" type="number" min="1" placeholder="开始" style="width: 60px;" disabled>' +
  255. '<span> ~ </span>' +
  256. '<input name="max" type="number" min="1" placeholder="结束" style="width: 60px;" disabled>' +
  257. '</form>' +
  258. '<div style="max-height: 300px; overflow-y: auto;">' +
  259. '<table border="1" style="font-size: 12px;">' +
  260. '<thead>' +
  261. '<tr>' +
  262. '<th style="width: 30px; min-width: 30px; font-weight: bold; text-align: center;">题号</th>' +
  263. '<th style="width: 60%; min-width: 130px; font-weight: bold; text-align: center;">题目(点击可复制)</th>' +
  264. '<th style="min-width: 130px; font-weight: bold; text-align: center;">答案(点击可复制)</th>' +
  265. '</tr>' +
  266. '</thead>' +
  267. '<tfoot style="display: none;">' +
  268. '<tr>' +
  269. '<th colspan="3" style="font-weight: bold; text-align: center;">答案提示框 已折叠</th>' +
  270. '</tr>' +
  271. '</tfoot>' +
  272. '<tbody>' +
  273. '<tr>' +
  274. '<td colspan="3" style="display: none;"></td>' +
  275. '</tr>' +
  276. '</tbody>' +
  277. '</table>' +
  278. '</div>' +
  279. '</div>'
  280. ).appendTo('body').on('click', 'button, td', function() {
  281. var len = $(this).prevAll('button').length;
  282. if (this.nodeName == 'TD') {
  283. $(this).prev().length && GM_setClipboard($(this).text());
  284. } else if (len === 0) {
  285. if (setting.loop) {
  286. clearInterval(setting.loop);
  287. delete setting.loop;
  288. len = [false, '已暂停搜索', '继续答题'];
  289. } else {
  290. setting.loop = setInterval(findAnswer, setting.time);
  291. len = [true, '正在搜索答案...', '暂停答题'];
  292. }
  293. setting.div.find('input').attr('disabled', len[0]);
  294. setting.div.children('div:eq(0)').html(function() {
  295. return $(this).data('html') || len[1];
  296. }).removeData('html');
  297. $(this).html(len[2]);
  298. } else if (len == 1) {
  299. location.reload();
  300. } else if (len == 2) {
  301. setting.div.find('tbody, tfoot').toggle();
  302. } else if (len == 3) {
  303. var $li = $('.el-scrollbar__wrap li'),
  304. $tip = $li.filter('.white, .yellow').eq(0);
  305. $tip.click().length ? setting.div.children('div:last').scrollTop(function() {
  306. var $tr = $('tbody tr', this).has('td:nth-child(1):contains(' + $tip.text() + ')');
  307. if (!$tr.length) return arguments[1];
  308. return $tr.offset().top - $tr.parents('table').offset().top; // $tr[0].offsetTop
  309. }) : $(this).hide();
  310. } else if (len == 4) {
  311. setting.tk_num++;
  312. GM_setValue('tk_num_1',setting.tk_num);
  313. setting.tk_num = GM_getValue('tk_num_1');
  314. console.log(setting.tk_num);
  315. parent.location.reload();
  316. }
  317. }).on('change', 'input', function() {
  318. setting[this.name] = this.value.match(/^\d+$/) ? parseInt(this.value) - 1 : -1;
  319. if (!this.value) setting[this.name] = this.name == 'num' ? 0 : undefined;
  320. }).detach(setting.hide ? '*' : 'html');
  321. setting.type = {
  322. 单选题: 1,
  323. 多选题: 2,
  324. 填空题: 3,
  325. 问答题: 4,
  326. '分析题/解答题/计算题/证明题': 5,
  327. '阅读理解(选择)/完型填空': 9,
  328. 判断题: 14
  329. };
  330. setting.lose = setting.num = setting.small = 0;
  331. $(document).keydown(function(event) {
  332. if (event.keyCode == 38) {
  333. setting.div.detach();
  334. } else if (event.keyCode == 40) {
  335. setting.div.appendTo('body');
  336. }
  337. });
  338. setting.loop = setInterval(findAnswer, setting.time, true);
  339. setInterval(function() {
  340. $(setting.queue.shift()).parent().click();
  341. }, 1E3);
  342. }
  343.  
  344. function findAnswer(tip) {
  345. if (setting.queue.length) {
  346. return;
  347. } else if (tip && !$('.answerCard').length) {
  348. return setting.div.children('div:eq(0)').data('html', '非自动答题页面').siblings('button:eq(0)').click();
  349. } else if (setting.max < 0 || setting.num < 0) {
  350. return setting.div.children('div:eq(0)').data('html', '范围参数应为 <font color="red">正整数</font>').siblings('button:eq(0)').click();
  351. } else if (setting.num >= $('.subject_stem').length || setting.num > setting.max) {
  352. // setting.div.children('button:eq(3)').toggle(!!setting.lose);
  353. tip = setting.lose ? '共有 <font color="red">' + setting.lose + '</font> 道题目待完善(已深色标注)' : '答题已完成';
  354. return setting.div.children('div:eq(0)').data('html', tip).siblings('button:eq(0), form').hide().click();
  355. } else if (!setting.curs.length) {
  356. setting.curs = $('.infoList span').map(function() {
  357. return $(this).text().trim();
  358. });
  359. if (!setting.curs.length) return;
  360. }
  361. var $TiMu = $('.subject_stem').eq(setting.num).parent(),
  362. $dom = $TiMu.find('.smallStem_describe').eq(setting.small).children('div').slice(1, -1),
  363. question = filterStyle($dom) || filterStyle($TiMu.find('.subject_describe')),
  364. type = $TiMu.find('.subject_type').text().match(/【(.+)】|$/)[1];
  365. type = type ? setting.type[type] || 0 : -1;
  366.  
  367. GM_xmlhttpRequest({
  368. method: 'POST',
  369. url: setting.tiku + 'v1/zhs',
  370. headers: {
  371. 'Content-type': 'application/x-www-form-urlencoded',
  372. },
  373. data: 'question=' + encodeURIComponent(question),
  374. timeout: setting.time,
  375. onload: function(xhr) {
  376. if (!setting.loop) {
  377. } else if (xhr.status == 200) {
  378. var obj = $.parseJSON(xhr.responseText.replace(/^操作数据失败!/,'')) || {};
  379. obj.answer = obj.data;
  380. if (obj.code) {
  381. setting.div.children('div:eq(0)').text('正在搜索答案...');
  382. var answer = obj.answer.replace(/&/g, '&').replace(/<([^i])/g, '<$1');
  383. obj.answer = /^http/.test(answer) ? '<img src="' + obj.answer + '">' : obj.answer;
  384. $(
  385. '<tr>' +
  386. '<td style="text-align: center;">' + $TiMu.find('.subject_num').text().trim().replace('.', '') + '</td>' +
  387. '<td title="点击可复制">' + (question.match('<img') ? question : question.replace(/&/g, '&').replace(/</g, '<')) + '</td>' +
  388. '<td title="点击可复制">' + (/^http/.test(answer) ? obj.answer : '') + answer + '</td>' +
  389. '</tr>'
  390. ).appendTo(setting.div.find('tbody')).css('background-color', function() {
  391. $dom = $dom.length ? $dom.closest('.examPaper_subject') : $TiMu;
  392. if (fillAnswer($dom, obj, type)) return '';
  393. setting.div.children('button:eq(3)').show();
  394. return 'rgba(0, 150, 136, 0.6)';
  395. });
  396. setting.small = ++setting.small < $TiMu.find('.smallStem_describe').length ? setting.small : (setting.num++, 0);
  397. } else {
  398. setting.div.children('div:eq(0)').html(obj.answer || '服务器繁忙,正在重试...');
  399. }
  400. setting.div.children('span').html(obj.msg || '');
  401. } else if (xhr.status == 403) {
  402. var html = xhr.responseText.indexOf('{') ? '请求过于频繁,建议稍后再试' : $.parseJSON(xhr.responseText).answer;
  403. setting.div.children('div:eq(0)').data('html', html).siblings('button:eq(0)').click();
  404. } else {
  405. setting.div.children('div:eq(0)').text('服务器异常,正在重试...');
  406. }
  407. },
  408. ontimeout: function() {
  409. setting.loop && setting.div.children('div:eq(0)').text('服务器超时,正在重试...');
  410. }
  411. });
  412.  
  413. }
  414.  
  415. function fillAnswer($TiMu, obj, type) {
  416. var $div = $TiMu.find('.nodeLab'),
  417. str = String(obj.answer).toCDB() || new Date().toString(),
  418. answer = str.split(/#|\x01|\|/),
  419. state = setting.lose;
  420. // $div.find(':radio:checked').prop('checked', false);
  421. obj.code > 0 && $div.each(function() {
  422. var $input = $('input', this)[0],
  423. tip = filterStyle('.node_detail', this).toCDB() || new Date().toString();
  424. if (tip.match(/^(正确|是|对|√|T|ri)$/)) {
  425. answer.join().match(/(^|,)(正确|是|对|√|T|ri)(,|$)/) && setting.queue.push($input);
  426. } else if (tip.match(/^(错误|否|错|×|F|wr)$/)) {
  427. answer.join().match(/(^|,)(错误|否|错|×|F|wr)(,|$)/) && setting.queue.push($input);
  428. } else if (type == 2) {
  429. Boolean($.inArray(tip, answer) + 1 || str.indexOf(tip) + 1) == $input.checked || setting.queue.push($input);
  430. } else {
  431. $.inArray(tip, answer) + 1 && setting.queue.push($input);
  432. }
  433. });
  434. if (setting.queue.length) {
  435. } else if (/^(1|2|14)$/.test(type)) {
  436. var $input = $div.find('input');
  437. $input.is(':checked') || (setting.none ? setting.queue.push($input[Math.floor(Math.random() * $input.length)]) : setting.lose++);
  438. } else if (/^[3-5]$/.test(type)) {
  439. answer = String(obj.answer).split(/#|\x01|\|/);
  440. str = $TiMu.find('textarea').each(function(index) {
  441. index = (obj.code > 0 && answer[index]) || '';
  442. this.value = index.trim();
  443. // if (this.value == this._value) return true;
  444. this.dispatchEvent(new Event('input'));
  445. this.dispatchEvent(new Event('blur'));
  446. }).length;
  447. (obj.code > 0 && answer.length == str) || setting.none || setting.lose++;
  448. } else {
  449. setting.none || setting.lose++;
  450. }
  451. return state == setting.lose;
  452. }
  453.  
  454. function collectData(obj, data) {
  455. setting.data = data = {};
  456. data.id = obj.id;
  457. data.name = obj.name;
  458. data.course = obj.courseName;
  459. data.chapter = obj.toChapter || obj.explain;
  460. data.timu = [];
  461. $.each(obj.workExamParts, function() {
  462. $.each(this.questionDtos, function() {
  463. if (this.questionOptions) return pushData(this, data.timu);
  464. $.each(this.questionChildrens, function() {
  465. pushData(this, data.timu);
  466. });
  467. });
  468. });
  469. GM_xmlhttpRequest({
  470. method: 'POST',
  471. url: setting.tiku +'report/zhs',
  472. headers: {
  473. 'Content-type': 'application/x-www-form-urlencoded',
  474. },
  475. data: 'data=' + encodeURIComponent(JSON.stringify(data))
  476. });
  477. }
  478.  
  479. function pushData(obj, arr) {
  480. arr.push({
  481. id: obj.id,
  482. question: filterStyle('<p>' + obj.name + '</p>'),
  483. option: $.map(obj.questionOptions, function(val) {
  484. return filterStyle('<p>' + val.content + '</p>');
  485. }),
  486. key: $.map(obj.questionOptions, function(val) {
  487. return val.id;
  488. }).join(),
  489. type: obj.questionType.id
  490. });
  491. }
  492.  
  493. function hookHiexam() {
  494. var ajax = new xhr();
  495. ajax.onload = function() {
  496. if (this.status != 200 || !this.responseURL.match('getDoQuestSingle')) return;
  497. var obj = JSON.parse(this.responseText).rt;
  498. $.each(obj.questionOptionList || [], function(index) {
  499. var $input = $('.TitleOptions-div input')[index];
  500. if (obj.questionTypeId == 1) {
  501. this.isCorrect && setting.queue.push($input);
  502. } else if (obj.questionTypeId == 2) {
  503. this.isCorrect == $input.checked || setting.queue.push($input);
  504. }
  505. });
  506. };
  507. return ajax;
  508. }
  509.  
  510. function filterStyle(dom, that) {
  511. var $dom = $(dom, that).clone().find('style').remove().end();
  512. return $dom.find('img[src]').replaceWith(function() {
  513. return $('<p></p>').text('<img src="' + $(this).attr('src') + '">');
  514. }).end().text().trim();
  515. }
  516.  

QingJ © 2025

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