网梯课堂助手————继续教育网课自动挂机脚本

自动挂机网梯课堂

  1. // ==UserScript==
  2. // @name 网梯课堂助手————继续教育网课自动挂机脚本
  3. // @namespace 1620535041@qq.com
  4. // @version 1.7
  5. // @description 自动挂机网梯课堂
  6. // @homepage https://www.zhaofupeng.com/
  7. // @author zfp123123
  8. // @match *://*.webtrn.cn/learnspace/learn/learn/*/index.action*
  9. // @run-at document-start
  10. // @require https://gf.qytechs.cn/scripts/18715-hooks/code/Hooks.js?version=661566
  11. // @grant none
  12. // @license MIT
  13. // ==/UserScript==
  14.  
  15. const NEXT_TAG_TEXT = `<span style="color:#19be6b;">【自动下一P】</span> `;
  16.  
  17. function nextP(){
  18.  
  19. }
  20.  
  21. function findVideo(element){
  22. if(!element) element = [window.document];
  23. for(let item of element){
  24. let document = item.nodeName === 'IFRAME' ? item.contentDocument : item;
  25. let videos = document.querySelectorAll('video');
  26. if(videos.length > 0){
  27. return videos;
  28. } else if (document.querySelectorAll('iframe').length > 0){
  29. let res = findVideo(document.querySelectorAll('iframe'));
  30. if(res) return res;
  31. }
  32. }
  33. }
  34.  
  35. function autoPlay() {
  36. const mainContent = document.getElementsByClassName('contentIframe')[0];
  37. mainContent.addEventListener("load",function(){
  38. const mainFrame = mainContent.contentDocument.getElementById("mainFrame");
  39. mainFrame.addEventListener("load",function(){
  40. const $ = window.jQuery;
  41. //视频重新加载时再执行一次脚本
  42. mainFrame.addEventListener("load",function(){autoPlay();});
  43. if(location.pathname.indexOf('blue') > -1)
  44. {
  45. const menus = [...$(mainContent).contents().find(".vcon").find("li")]; //左侧菜单
  46. const selectMenu = $(mainContent).contents().find(".vcon").find("li.select")[0]; //当前选中的菜单
  47. const selectMenuIndex = menus.findIndex(e=>e===selectMenu); //当前选中菜单的游标
  48.  
  49. const nextBtn = $(mainContent).contents().find(".rtarr")[0]; //标签栏下一个按钮
  50. const tabs = [...$(mainContent).contents().find(".menub")]; //标签栏
  51. const selectTab = $(mainContent).contents().find(".menubu")[0]; //当前选中的标签
  52. const selectTabIndex = tabs.findIndex(e=>e===selectTab); //当前选中标签的游标
  53.  
  54. nextP = function(){
  55. if(tabs.length - selectTabIndex >1){
  56. nextBtn.click();
  57. }else if(menus.length - selectMenuIndex > 1){
  58. menus[selectMenuIndex + 1].click();
  59. $(menus[selectMenuIndex + 1]).find("a").click()
  60. }
  61. }
  62. }else if(location.pathname.indexOf('templatethree') > -1 ||
  63. location.pathname.indexOf('templateeight') > -1)
  64. {
  65. const title = $(mainFrame).contents().find(".s_title").text();
  66. const items = [...$(mainContent).contents().find('.s_point').filter("[itemtype='video']")];
  67. const selectedItem = items.find(e=>e.children[2].innerText.match(title));
  68. const selectedItemIndex = items.indexOf(selectedItem);
  69. items.forEach((i)=>{
  70. if(i.children[2].innerHTML.match(NEXT_TAG_TEXT)){
  71. i.children[2].innerHTML = i.children[2].innerHTML.replace(NEXT_TAG_TEXT,'');
  72. }
  73. });
  74.  
  75. if(items.length - selectedItemIndex > 0){
  76. const nextItem = items[selectedItemIndex + 1];
  77. if(!nextItem.children[2].innerHTML.match(NEXT_TAG_TEXT)){
  78. nextItem.children[2].innerHTML = `${NEXT_TAG_TEXT}${nextItem.children[2].innerText}`;
  79. }
  80. nextP = function(){
  81. nextItem.click();
  82. }
  83. }
  84. }
  85.  
  86. let interval = setInterval(() => {
  87. let videos = findVideo();
  88. if(videos && videos.length > 0){
  89. for(let v of videos){
  90. v.addEventListener('ended',function(){
  91. videoIntervals.forEach(e=>clearInterval(e));
  92. nextP();
  93. });
  94. videoIntervals.push(setInterval(() => {
  95. if( v.volume !== 0)
  96. v.volume = 0;
  97. if(v.playbackRate !== 1.5)
  98. v.playbackRate = 1.5;
  99. }, 100));
  100. }
  101. clearInterval(interval);
  102. }
  103. }, 100);
  104.  
  105. const studyType = $(mainFrame)[0].contentWindow._maq[11][1];
  106. if(!(studyType !== 'video' || studyType !== 'courseware'))
  107. {
  108. nextP();
  109. }
  110.  
  111. });
  112. });
  113. }
  114.  
  115. var videoIntervals =[];
  116.  
  117. (function() {
  118. 'use strict';
  119. /**
  120. * 关闭30分钟每次的检查
  121. */
  122. Hooks.set(window, "jQuery", function ( target, propertyName, ignored, jQuery ) {
  123. Hooks.method(jQuery, "studyTime", function ( target, methodName, method, thisArg, args ) {
  124. args[0].clickAuth = false;
  125. args[0].periodRemind = false;
  126. args[0].randomRemind = false;
  127. console.log('已关闭30分钟每次的检查');
  128. return Hooks.Reply.method( arguments );
  129. });
  130. return Hooks.Reply.set( arguments );
  131. });
  132. document.addEventListener('DOMContentLoaded',function(){
  133. autoPlay();
  134. });
  135. })();

QingJ © 2025

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