Greasy Fork镜像 支持简体中文。

智慧树自动播放

就是自动智慧树自动播放

  1. // ==UserScript==
  2. // @name 智慧树自动播放
  3. // @namespace fadetube
  4. // @version 1.1.0
  5. // @description 就是自动智慧树自动播放
  6. // @description 大部分使用了大佬的代码,本脚本只修改了切换下一视频的判断
  7. // @author 垚垚垚垚垚垚垚垚垚
  8. // @match *://*.zhihuishu.com/*
  9. // @connect cx.icodef.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. // @original-script https://gf.qytechs.cn/scripts/380506
  18. // @original-author wyn665817
  19. // @original-license MIT
  20. // ==/UserScript==
  21.  
  22. // 设置修改后,需要刷新或重新打开网课页面才会生效
  23. var setting = {
  24. // 5E3 == 5000,科学记数法,表示毫秒数
  25. time: 5E3 // 默认响应速度为5秒,不建议小于3秒
  26.  
  27. // 1代表开启,0代表关闭
  28. ,video: 1 // 视频支持课程、见面课,默认开启
  29. ,jump: 1 // 自动切换视频,支持课程、见面课,默认开启
  30.  
  31. // 仅开启video时,修改此处才会生效
  32. ,line: '流畅' // 视频播放的默认线路,可选参数:['高清', '流畅', '校内'],默认'流畅'
  33. ,vol: '0' // 默认音量的百分数,设定范围:[0,100],'0'为静音,默认'0'
  34. ,speed: '1.5' // 进度统计速率,高倍率可以快速完成任务点,设定范围:(0,+∞),默认'1.5'倍
  35. // 上方参数支持在页面改动,下方参数仅支持代码处修改
  36. ,que: 1 // 屏蔽视频时间点对应的节试题,取消屏蔽则自动切换为模拟点击关闭弹题,默认开启
  37. ,danmu: 0 // 见面课弹幕,关闭后在网页中无法手动开启,默认关闭
  38. ,habit: '0' // 限制视频挂机时长,单位是分钟,如需挂机习惯分,可以修改参数为'30',默认不限制
  39. ,none: 0
  40. ,hide: 0
  41. ,work: 1
  42.  
  43. },
  44. _self = unsafeWindow,
  45. url = location.pathname,
  46. $ = _self.jQuery,
  47. xhr = _self.XMLHttpRequest;
  48.  
  49. setting.notice = '智慧树傻不拉几';
  50.  
  51. String.prototype.toCDB = function() {
  52. return this.replace(/\s/g, '').replace(/[\uff01-\uff5e]/g, function(str) {
  53. return String.fromCharCode(str.charCodeAt(0) - 65248);
  54. }).replace(/[“”]/g, '"').replace(/[‘’]/g, "'").replace(/。/g, '.');
  55. };
  56.  
  57. // setting.time += Math.ceil(setting.time * Math.random()) - setting.time / 2;
  58. setting.queue = setting.curs = [];
  59.  
  60. if (!$) {
  61. } else if (url.match('/videoList')) {
  62. $.tmDialog.alert({content: '智慧树你和我', title: '摇咿摇咿摇'});
  63. } else if (url == '/videoStudy.html') {
  64. setting.habit *= 6E4;
  65. setting.video && hookVideo(_self.vjsComponent, 1);
  66. setting.jump && setInterval(checkToNext, setting.time);
  67. } else if (url == '/portals_h5/2clearning.html') {
  68. setting.video && hookVideo(_self.vjsComponent, 2);
  69. setting.jump && setInterval(checkToNext, setting.time);
  70. } else if (url == '/live/vod_room.html') {
  71. setting.video && hookVideo(_self.vjsComponent);
  72. setting.jump && setInterval(checkToNext, setting.time, 1);
  73. } else if (location.hostname.match('examh5')) {
  74. setTimeout(relieveLimit, 100, document);
  75. if (location.hash.match(/dohomework|doexamination/) && setting.work) beforeFind();
  76. $(window).on('hashchange', function() {
  77. setting.work && location.reload();
  78. });
  79. } else if (url.match('/sourceLearning')) {
  80. setting.video && hookVideo(_self.vjsComponent, 3);
  81. setting.jump && setInterval(checkToNext, setting.time, $('.source-file-item'));
  82. } else if (url == '/shareCourse/questionDetailPage') {
  83. setTimeout(relieveLimit, 100, document);
  84. $('textarea[oncut]').each(function() {
  85. setTimeout(relieveLimit, 100, this);
  86. });
  87. } else if (url.match('exerciseList') && setting.work) {
  88. _self.XMLHttpRequest = hookHiexam;
  89. setInterval(function() {
  90. $(setting.queue.shift()).parent().click();
  91. }, 1E3);
  92. setting.jump && setInterval(function() {
  93. // var $li = setting.queue.length ? $() : $('.jobclassallnumber-div li');
  94. // $li.slice($li.index($('.greenbordercur')) + 1).not('.greenbgcur').eq(0).click();
  95. setting.queue.length || $('.Topicswitchingbtn:contains(下一题)').click();
  96. }, setting.time);
  97. }
  98.  
  99.  
  100.  
  101. function totalTime() {
  102. var player = _self.PlayerStarter.playerArray[0].player;
  103. setting.habit -= player.paused() ? 0 : setting.time;
  104. if (setting.habit >= 0) return;
  105. clearInterval(setting.tip);
  106. player.pause();
  107. $.getScript('//cdn.jsdelivr.net/gh/sentsin/layer/dist/layer.js', function() {
  108. _self.layer.open({content: '已达到挂机限制时间', title: '智慧树网课助手提示', end: function() {
  109. setting.habit = 0;
  110. }});
  111. });
  112. }
  113.  
  114. //这里是原创的,非原作者源码*********************************************************************
  115. function checkToNext(tip) {
  116. let p_progress = parseInt(document.querySelector('.vjs-play-progress').style.width);
  117. let a = document.getElementById('fileId').value;
  118. let c_id = parseFloat(a);
  119. if (p_progress > 95){
  120. c_id = c_id + 1;
  121. document.getElementById('file_'+c_id).click();
  122. }
  123. }
  124.  
  125. function doTest() {
  126. if (!$('.dialog-test').length) {
  127. } else if (setting.queue.length) {
  128. $(setting.queue.shift()).parent().click();
  129. } else if (!$('.answer').length) {
  130. $('.topic-item').eq(0).click();
  131. } else if (!$('.right').length) {
  132. var tip = $('.answer span').text().match(/[A-Z]/g) || [];
  133. if (tip.length == 1) return $('.topic-option-item:contains(' + tip[0] + ')').click();
  134. $('.topic-option-item').each(function() {
  135. $.inArray($(this).text().slice(0, 1), tip) < 0 == $(this).hasClass('active') && setting.queue.push(this);
  136. });
  137. } else if ($('.btn-next:enabled').length) {
  138. $('.btn-next:enabled').click();
  139. } else {
  140. $('.dialog-test .btn').click();
  141. _self.PlayerStarter.playerArray[0].player.play();
  142. }
  143. }
  144.  
  145. function hookVideo(Hooks, tip) {
  146. // _self.PlayerUtil.debugMode = true;
  147. _self.vjsComponent = function() {
  148. var config = arguments[0],
  149. options = config.options,
  150. line = $.map(options.sourceSrc.lines, function(value) {
  151. return value.lineName.replace('标准', '高清');
  152. }),
  153. vol = setting.vol > 100 ? 100 : setting.vol,
  154. rate = tip == 3 ? [1, 1.25, 1.5, 2, 2.5, 3] : [1, 1.25, 1.5];
  155. vol = Math.round(vol) / 100;
  156. options.volume = vol > 0 ? vol : 0;
  157. options.autostart = true;
  158. setting.speed = setting.speed > 0 ? +setting.speed : 1;
  159. options.rate = $.inArray(setting.speed, rate) < 0 ? options.rate : setting.speed;
  160. tip && config.callback.playbackRate(setting.speed);
  161. options.chooseLine = $.inArray(setting.line, line) + 1 || options.chooseLine + 1;
  162. options.src = options.sourceSrc.lines[--options.chooseLine].lineUrl || options.src;
  163. if (!setting.danmu) {
  164. config.defOptions.control.danmuBtn = false;
  165. delete options.control.danmuBtn;
  166. }
  167. Hooks.apply(this, arguments);
  168. config.player.on('loadstart', function() {
  169. this.loop(true);
  170. this.play();
  171. $('.speedBox span').text('X ' + setting.speed);
  172. });
  173. };
  174. $(document).on('click', '.definiLines b', function() {
  175. setting.line = ({xiaonei: '校内', line1gq: '高清', line1bq: '流畅'})[this.classList[0]];
  176. }).on('mouseup click', function() {
  177. setting.vol = _self.PlayerStarter.playerArray[0].player.cache_.volume * 100;
  178. }).on('click', '.speedList div', function() {
  179. setting.speed = $(this).attr('rate');
  180. });
  181. if (tip != 1) return;
  182. setting.tip = setting.habit && setInterval(totalTime, setting.time);
  183. setInterval(doTest, 1E3);
  184. _self.XMLHttpRequest = setting.que ? function() {
  185. var ajax = new xhr(),
  186. open = ajax.open;
  187. ajax.open = function(method, url) {
  188. if (url.match('/loadVideoPointerInfo')) method = 'OPTIONS';
  189. return open.apply(this, arguments);
  190. };
  191. return ajax;
  192. } : xhr;
  193. }
  194. function relieveLimit(doc) {
  195. if (!doc.oncut && !doc.onselectstart) return setTimeout(relieveLimit, 100, doc);
  196. doc.oncontextmenu = doc.onpaste = doc.oncopy = doc.oncut = doc.onselectstart = null;
  197. }
  198.  
  199. function hookHiexam() {
  200. var ajax = new xhr();
  201. ajax.onload = function() {
  202. if (this.status != 200 || !this.responseURL.match('getDoQuestSingle')) return;
  203. var obj = JSON.parse(this.responseText).rt;
  204. $.each(obj.questionOptionList || [], function(index) {
  205. var $input = $('.TitleOptions-div input')[index];
  206. if (obj.questionTypeId == 1) {
  207. this.isCorrect && setting.queue.push($input);
  208. } else if (obj.questionTypeId == 2) {
  209. this.isCorrect == $input.checked || setting.queue.push($input);
  210. }
  211. });
  212. };
  213. return ajax;
  214. }
  215.  
  216. function filterStyle(dom, that) {
  217. var $dom = $(dom, that).clone().find('style').remove().end();
  218. return $dom.find('img[src]').replaceWith(function() {
  219. return $('<p></p>').text('<img src="' + $(this).attr('src') + '">');
  220. }).end().text().trim();
  221. }

QingJ © 2025

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