智慧树刷课,作业脚本(暂时不能考试)

智慧树刷课脚本,支持自动刷课,自动跳转下一节,作业自动答题

  1. // ==UserScript==
  2. // @name 智慧树刷课,作业脚本(暂时不能考试)
  3. // @namespace xp9797
  4. // @version 1.0
  5. // @description 智慧树刷课脚本,支持自动刷课,自动跳转下一节,作业自动答题
  6. // @author xp9797
  7. // @connect ykhulian.com
  8. // @run-at document-end
  9. // @connect http://c.ykhulian.com/main.css
  10. // @match *://*.zhihuishu.com/stuExamWeb*
  11. // @match https://www.zhihuishu.com/portals_h5/*
  12. // @match https://studyh5.zhihuishu.com/portals_h5/2clearning.html*
  13. // @match https://studyh5.zhihuishu.com/videoStudy*
  14. // @grant unsafeWindow
  15. // @grant GM_xmlhttpRequest
  16. // @grant GM_addStyle
  17. // @grant GM_getResourceText
  18. // @resource skcss https://c.ykhulian.com/resourse/components/main.css
  19. // @require https://gf.qytechs.cn/scripts/406149-skeleton-mediautil/code/skeleton-MediaUtil.js?version=820961
  20. // @require https://gf.qytechs.cn/scripts/406147-skeleton%E8%84%9A%E6%9C%AC%E7%AA%97%E5%8F%A3%E7%BB%98%E5%88%B6/code/skeleton%E8%84%9A%E6%9C%AC%E7%AA%97%E5%8F%A3%E7%BB%98%E5%88%B6.js?version=820972
  21. // @require https://gf.qytechs.cn/scripts/406148-skeleton-answerutil/code/skeleton-AnswerUtil.js?version=820959
  22. // ==/UserScript==
  23.  
  24. (function() {
  25. var rate= 1.5 //默认播放速度,1.5倍速
  26. var stop_time = 30*60*1000 //自动关闭时长,默认半个钟
  27. var $=unsafeWindow.jQuery;
  28. var url=window.location.href;
  29. setTimeout(function(){document.onselectstart=null},2000);//解除智慧树网页不能复制的限制
  30.  
  31. let skcss = GM_getResourceText('skcss')
  32. GM_addStyle(skcss)
  33.  
  34. function start(all_li,with_out_what){
  35. //获取所有要播放的视频
  36. var all=$(all_li);
  37. var new_video=new Array();
  38. for(let i =0 ;i<all.length;i++){
  39. if(all.eq(i).find(with_out_what).length==0){
  40. new_video.push(all.eq(i)[0]);
  41. }
  42. }
  43. console.log(new_video);
  44. //视频播放组件的设置参数:
  45. var vusetting = {
  46. auto: true,
  47. muted: true,
  48. playbackRate: rate,
  49. timeout_reload: true,
  50. debug: true,
  51. MediaEndEvent() {
  52. console.log("媒体播放完毕");
  53. new_video.shift().click(); // 队列模式
  54. setTimeout(function(){
  55. var mu = new MediaUtil($('video'), vusetting);//播放
  56. mu.start();
  57. },2000);
  58. },
  59. timeOut() {
  60. console.log("媒体加载超时");
  61. }
  62. }
  63. var mu = new MediaUtil($('video'), vusetting);
  64. mu.start();//开始播放
  65.  
  66. //题目弹窗,选择A,关闭
  67. setInterval(function(){
  68. if($('.speedBox').find('span').text()=="X 1.0")$('.speedTab15').click();
  69. if($('.topic-item').length!=0){
  70. setTimeout("$('.topic-item').eq(0).click();",500)//选择A
  71. setTimeout("$('div.btn').eq(0).click();",1000)//关闭
  72. }
  73.  
  74. },2000);
  75. }
  76.  
  77.  
  78.  
  79. var index=0;
  80.  
  81. //把所有选中的答案清空
  82. function clear_options(){
  83. setTimeout(function(){
  84. let options=$('.examPaper_subject').find('.examquestions-answer.onChecked');
  85. //把所有选中的答案清空
  86. var i=0;
  87. var s=setInterval(function(){
  88. console.log("清空选中的选项...");
  89. options.eq(i++).click();
  90. if(i>options.length){
  91. clearInterval(s);
  92. $('#ready').text('清除完毕!开始自动答题');
  93. setTimeout(function(){autoAnswer()},3000);
  94. }
  95. },200);
  96.  
  97. },3000);
  98.  
  99. }
  100.  
  101. function autoAnswer(){
  102. if($('#ready')!=undefined)$('#ready').remove();
  103. var test_topicText=$('.examPaper_subject .subject_describe')//所有题目的描述
  104. var regexp= /===|---|#/;
  105. var question=test_topicText.eq(index).text().replace(/\s/g,'');
  106. console.log(question);
  107. console.log($('.examPaper_subject .subject_describe'));
  108. GM_xmlhttpRequest({
  109. type: "get",
  110. url: "http://c.ykhulian.com/chati/0/"+question ,
  111. dataType: "json",
  112. onload: function (r) {
  113. var json = JSON.parse(r.responseText);
  114. var answer = json.answer;
  115. var json_question = json.question;
  116. //==============================================如果找不到答案==============================================
  117. if (answer.indexOf('抱歉找不到结果') != -1) {
  118. test_topicText.eq(index).append('<p class="mysk" style="background-color:rgb(255, 92, 92, 0.4)">【问题】:无<br>【回答】:抱歉找不到结果</p>');
  119. if (index++ < test_topicText.length - 1) setTimeout(autoAnswer(), 3000);
  120. else $('#none').css('display','block');
  121. return;
  122. }
  123. test_topicText.eq(index).append('<p class="mysk" style="background-color:rgb(69, 204, 98,0.2)">【问题】:' + json_question.substring(json_question.indexOf('】') + 1) + '。</p>');
  124. test_topicText.eq(index).append('<p class="mysk" style="background-color:rgb(69, 204, 98, 0.2)">【回答】:' + answer + '。</p>');
  125.  
  126. var options=$('.examPaper_subject').eq(index).find('.examquestions-answer');
  127. var input = $('.examPaper_subject').eq(index).find('.subject_node input');
  128.  
  129. var answer_array = answer.split(regexp);
  130.  
  131. var opt_array=new Array();
  132. for(let i =0 ;i <options.length;i++){
  133. opt_array.push(options.eq(i).text());
  134. }
  135.  
  136. //获取答案
  137. var au=new AnswerUtil(question,answer_array,opt_array);
  138. console.log(answer_array);
  139. console.log(au.getAnswer());
  140. let au_answer=au.getAnswer();
  141.  
  142. var j=0;
  143. loop(function(){
  144. options.eq(au_answer[j++]).click();
  145. },au_answer.length);
  146. drawDiv(test_topicText.eq(index),index, au_answer.length==0?0:1);
  147.  
  148. setTimeout(function(){
  149. if(au_answer.length==0){
  150. test_topicText.eq(index).append('<p class="mysk" style="background-color:rgb(255, 92, 92, 0.4)">没有符合回答的答案,请自行选择</p>');
  151. }
  152. if(index<test_topicText.length){
  153. index++;
  154. setTimeout(function(){autoAnswer()},3000);
  155. }
  156. },options.length*200);
  157.  
  158.  
  159. },
  160. onerror: function(e){
  161. console.log('服务器错误');
  162. }
  163. })
  164. };
  165.  
  166. function loop(fn,times){
  167. let i=0;
  168. var s=setInterval(function(){
  169. fn();
  170. if(i>times)clearInterval(s);
  171. },200);
  172. }
  173.  
  174.  
  175. var sleep = function(time) {
  176. var startTime = new Date().getTime() + parseInt(time, 10);
  177. while(new Date().getTime() < startTime) {}
  178. };
  179.  
  180. //绘制回答对错的框
  181. function drawDiv(questions,index, isclick) {
  182. questions.attr("id", "topic" + index);
  183.  
  184. var topic_div = $("<a href='#topic" + index + "'>" + (index + 1) + ((index + 1) >= 10 ? "" : " ") + "." + ((index + 1) >= 10 ? "" : " ") + "<span style='font-weight:bold'>" + (isclick == 1 ? "√" : "×") + "</span></a>");
  185. var divcss = {
  186. float: "left",
  187. color: (isclick == 1 ? "green" : "red"),
  188. padding: "5px",
  189. border: "1px solid",
  190. margin: " 5px"
  191. };
  192. topic_div.css(divcss);
  193. $('#content').append(topic_div);
  194.  
  195. }
  196.  
  197.  
  198.  
  199.  
  200.  
  201. if(url.indexOf('zhihuishu.com/videoStudy')!=-1){
  202. //绘制窗口
  203. drawWindow();
  204.  
  205. console.log('开始刷视频');
  206. let time = 0
  207. $('#content').html('<div ><p id="rate_txt" >播放速度:默认1.5倍速</p>');
  208. $('#skdiv').append('<button id="back">半小时自动关闭</button>');
  209. $('#back').click( function(){
  210. if(time==0){
  211. time = stop_time
  212. console.log("半小时自动关闭");setTimeout(function(){window.history.back(-1);},stop_time)
  213. setInterval(function(){
  214. if(time>1000){
  215. $('#back').text("剩余秒:"+(time-=1000))
  216. }
  217. },1000)
  218. }
  219. })
  220.  
  221. setTimeout(function(){start('li.clearfix.video','.time_icofinish')},3000)//开始刷共享课视频,传入视频li元素:li.clearfix.video和完成的视频.time_icofinish,即可刷课
  222.  
  223. }else if(url.indexOf('zhihuishu.com/portals_h5/2clearning.html#/course2cStudy')!=-1){
  224. drawWindow();
  225. console.log('开始刷视频');
  226. $('#content').html('<div ><p id="rate_txt" >播放速度:默认1.5倍速</p>');
  227. setTimeout(function(){start('li.lessonItem','.icon.finishProgress')},3000)//开始刷兴趣课视频,传入视频li元素:li.lessonItem 和完成的视频包含的元素:icon.finishProgress即可刷课。
  228. }
  229. else if(url.indexOf('zhihuishu.com/stuExamWeb')!=-1 &&url.indexOf('dohomework')!=-1 ){
  230. drawWindow();
  231. $('#content').html('<div ><p id="ready" >正在准备自动答题中...(清除选择)</p>');
  232. console.log('开始自动答题');
  233.  
  234. clear_options();
  235.  
  236. }
  237.  
  238.  
  239.  
  240. })();

QingJ © 2025

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