智慧树网课自动刷新跳转下一门课程

每隔一段时间刷新网页防止网络连接失败,并可以根据课程完成度自动跳转到用户设置的下一门课程

  1. // ==UserScript==
  2. // @name 智慧树网课自动刷新跳转下一门课程
  3. // @version 1.8
  4. // @description 每隔一段时间刷新网页防止网络连接失败,并可以根据课程完成度自动跳转到用户设置的下一门课程
  5. // @author 冷弋白
  6. // @match *://studyh5.zhihuishu.com/*
  7. // @icon https://z3.ax1x.com/2021/05/17/g2l0Z8.png
  8. // @namespace https://gf.qytechs.cn/users/702892
  9. // ==/UserScript==
  10. window.addEventListener('load',function(){
  11. var num = 1200;
  12. var text = document.createElement('div');
  13. text.classList.add('text');
  14. document.body.appendChild(text)
  15. var Text = document.querySelector('.text');
  16. Text.style.fontSize = '20px'
  17. Text.style.color = '#fff'
  18. Text.style.position = 'absolute'
  19. Text.style.zIndex = '99999'
  20. Text.style.top = '60px'
  21. Text.style.left = '0px'
  22. Text.style.padding = '10px'
  23. Text.style.textShadow = '0 0 10px'
  24. Text.style.backgroundColor = '#3d84ff'
  25. Text.style.textAlign = 'center'
  26. Text.innerHTML = '正在加载观看数据...'
  27.  
  28. var lyb = document.createElement('div');
  29. lyb.classList.add('lyb');
  30. document.body.appendChild(lyb);
  31. var LYB = document.querySelector('.lyb');
  32. LYB.style.width = '200px'
  33. LYB.style.height = '230px'
  34. LYB.style.fontSize = '40px'
  35. LYB.style.color = '#fff'
  36. LYB.style.position = 'absolute'
  37. LYB.style.zIndex = '99999'
  38. LYB.style.top = '60px'
  39. LYB.style.left = '480px'
  40. LYB.style.textShadow = '0 0 10px'
  41. LYB.style.backgroundColor = '#3d84ff'
  42. LYB.style.textAlign = 'center'
  43. LYB.style.display = 'none';
  44. LYB.style.flexDirection = 'column';
  45. LYB.style.justifyContent = 'center';
  46. LYB.style.alignItems = 'center';
  47.  
  48. var head = document.createElement('img');
  49. head.classList.add('headImg');
  50. LYB.appendChild(head);
  51. var headImg = document.querySelector('.headImg');
  52. headImg.src = 'https://z3.ax1x.com/2021/05/17/g2l0Z8.png'
  53. headImg.style.width = '100px'
  54. headImg.style.borderRadius = '50%'
  55.  
  56. var name = document.createElement('span');
  57. name.classList.add('name');
  58. LYB.appendChild(name);
  59. var lybName = document.querySelector('.name');
  60. lybName.innerHTML = '冷弋白'
  61. lybName.style.fontSize = '25px'
  62.  
  63. var qq = document.createElement('a');
  64. qq.classList.add('qq');
  65. LYB.appendChild(qq);
  66. var QQ = document.querySelector('.qq');
  67. QQ.innerHTML = '点击此处联系我'
  68. QQ.target = '_blank'
  69. QQ.href = 'https://wpa.qq.com/msgrd?v=3&uin=1329670984&site=qq&menu=yes'
  70. QQ.style.fontSize = '14px'
  71. QQ.style.color = '#ccc'
  72. QQ.style.textDecoration = 'underline';
  73.  
  74. var input = document.createElement('input');
  75. input.classList.add('hrefInput');
  76. document.body.appendChild(input)
  77. var hrefInput = document.querySelector('.hrefInput');
  78. hrefInput.style.position = 'absolute'
  79. hrefInput.style.width = '666px'
  80. hrefInput.style.fontSize = '14px'
  81. hrefInput.style.left = '0px'
  82. hrefInput.style.top = '290px'
  83. hrefInput.value = localStorage.getItem('href')
  84. hrefInput.placeholder = '输入的链接10秒后自动存入本地,若为空,10秒后会自动填充,无需担心因浏览器刷新而无法跳转'
  85. hrefInput.style.outline = 'none'
  86. hrefInput.style.zIndex = '99999'
  87. hrefInput.style.padding = '5px'
  88. hrefInput.style.backgroundColor = 'rgb(61, 132, 255)'
  89. hrefInput.style.color = '#fff'
  90. hrefInput.style.border = '2px solid #fff'
  91. hrefInput.style.display = 'none'
  92. var inputNum = 6;
  93. setInterval(function(){
  94. if(localStorage.getItem('href') == null){
  95. localStorage.setItem("href",hrefInput.value);
  96. }else if(hrefInput.value == ''){
  97. hrefInput.value=localStorage.getItem("href");
  98. }else {
  99. localStorage.setItem("href",hrefInput.value);
  100. }
  101. },10000)
  102. function times(arr) {
  103. var allTime = 0;
  104. arr.forEach(function(a) {
  105. allTime += A(a);
  106. });
  107. function A(time) {
  108. var min = parseInt(time.substr(3, 2)) * 60;
  109. var s = parseInt(time.substr(6, 2));
  110. var ss = min + s;
  111. return ss;
  112. }
  113. return {
  114. hour: parseInt((allTime/ 3 * 2) / 60 / 60),
  115. min: parseInt((allTime / 3 * 2) / 60) % 60,
  116. s: parseInt(((allTime / 3 * 2) % 60) % 60),
  117. ss:parseInt(allTime / 3 * 2),
  118. sss:parseInt(allTime / 3 * 2 * 1000),
  119. };
  120. }
  121. var timeArr = [],finish,allTime,everyTime,finishTime,nowTime,lightDark;
  122. setInterval(function(){
  123. nowTime = new Date().getTime()
  124. },1000)
  125. setTimeout(function(){
  126. //获取已经完成的课程数量
  127. finish = document.querySelectorAll('.time_icofinish').length
  128. //获取所有课程
  129. allTime = document.querySelectorAll('#app .video-study .box-content .box-right .el-scrollbar .el-scrollbar__wrap .el-scrollbar__view .time')
  130. //将获取的所有课程时间添加进数组
  131. allTime.forEach(function(a){
  132. timeArr.push(a.innerHTML)
  133. })
  134. //删除已经完成的课程时长
  135. for(var i = 0;i < finish;i++){
  136. timeArr.shift();
  137. }
  138. //几点完成
  139. var a = nowTime + times(timeArr).sss
  140. finishTime = new Date(a).toLocaleString();
  141. //多少秒完成
  142. var b = times(timeArr).ss;
  143.  
  144. var timea = +new Date(finishTime.replace(/[\u4e00-\u9fa5]/g, ' '));
  145. var countDown = times(timeArr).ss
  146. setInterval(function(){
  147. lightDark = document.querySelector('.Patternbtn-div').querySelector('p')
  148. finish = document.querySelectorAll('.time_icofinish').length;
  149. LYB.style.display = 'flex';
  150. hrefInput.style.display = 'block'
  151. if(lightDark.innerHTML == '白昼模式'){
  152. Text.style.backgroundColor = '#3d84ff'
  153. LYB.style.backgroundColor = '#3d84ff'
  154. hrefInput.style.backgroundColor = '#3d84ff'
  155. }else{
  156. Text.style.backgroundColor = '#222222'
  157. LYB.style.backgroundColor = '#222222'
  158. hrefInput.style.backgroundColor = '#222222'
  159. }
  160. b-=1
  161. everyTime = times(timeArr).hour + '时' + times(timeArr).min + '分' + times(timeArr).s + '秒';
  162. Text.innerHTML ='为了防止刷课时间久了导致视频连接失败而暂停<br>'+ num + '秒后将自动刷新浏览器<br>您已完成' + finish + '节课<br>还有'+
  163. (allTime.length - finish) + '节课等着您完成<br>在1.5倍速的状态下,您需要花'+
  164. everyTime+'<br>也就是'+b+'秒后将看完当前课程<br>预计在'+
  165. finishTime+'看完当前课程<br>看完后将自动跳转至您在下方输入框输入的网页链接';
  166. num--;
  167. if (num == 0) {
  168. location.reload();
  169. }
  170. if(finish==allTime.length){
  171. window.open(hrefInput.value)
  172. window.close()
  173. }
  174. },1000)
  175. },2000)
  176. })

QingJ © 2025

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