智慧树网课助手【MCD】

【无需TOKEN】自动挂机看知到MOOC,支持屏蔽弹窗题目、自动切换下一节,章测试和考试支持自动答题,视频自动倍速播放、线路选择、默认静音等,解除各类功能限制,开放自定义参数 仅作接口更换,稳定性未知!!建议夜深人静时悄悄食用

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

QingJ © 2025

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