大红鸟

NBUFE大红鸟 长江雨课堂 网课自动化脚本

  1. // ==UserScript==
  2. // @name 大红鸟
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.3
  5. // @description NBUFE大红鸟 长江雨课堂 网课自动化脚本
  6. // @author hqzqaq
  7. // @icon https://img0.baidu.com/it/u=2503147746,2175442696&fm=253&fmt=auto&app=138&f=JPEG?w=508&h=500
  8. // @grant GM_getValue
  9. // @grant GM_setValue
  10. // @grant unsafeWindow
  11. // @match https://nbufe.yuketang.cn/pro/*
  12. // @run-at document-end
  13. // @license MIT
  14. // @require https://cdn.bootcss.com/jquery/1.10.2/jquery.min.js
  15. // ==/UserScript==
  16.  
  17. (function () {
  18. "use strict";
  19. // 多长时间刷新一下页面,单位 分钟
  20. const reloadTime = 10;
  21. // 视频播放速率,可选值 [1,1.25,1.5,2],默认为二倍速
  22. const rate = 2;
  23.  
  24. window.onload = function () {
  25. // 网课页面跳转
  26. function getElTooltipItemList() {
  27. return document.getElementsByClassName("el-tooltip leaf-detail");
  28. }
  29.  
  30. function getElTooltipList() {
  31. return document.getElementsByClassName("el-tooltip f12 item");
  32. }
  33.  
  34. // 静音
  35. function claim() {
  36. $(
  37. "#video-box > div > xt-wrap > xt-controls > xt-inner > xt-volumebutton > xt-icon"
  38. ).click();
  39. }
  40.  
  41. function fun(className, selector)
  42. {
  43. var mousemove = document.createEvent("MouseEvent");
  44. mousemove.initMouseEvent("mousemove", true, true, unsafeWindow, 0, 10, 10, 10, 10, 0, 0, 0, 0, 0, null);
  45. document.getElementsByClassName(className)[0].dispatchEvent(mousemove);
  46. document.querySelector(selector).click();
  47. }
  48.  
  49. // 加速
  50. function speed() {
  51. let keyt = '';
  52. if(rate === 2 || rate === 1){
  53. keyt = "[keyt='" + rate + ".00']"
  54. }else{
  55. keyt = "[keyt='" + rate + "']"
  56. }
  57. fun("xt_video_player_speed", keyt);
  58. }
  59.  
  60.  
  61.  
  62. const getElementInterval = setInterval(function () {
  63. const elTooltipList = getElTooltipList();
  64. const elTooltipItemList = getElTooltipItemList();
  65. if (elTooltipList) {
  66. for (let index = 0; index < elTooltipList.length; index++) {
  67. const element = elTooltipList[index];
  68. const textContent = element.textContent;
  69. //const textContent = ''
  70. if (textContent === "未开始" || textContent === "未读") {
  71. // 判断是否是习题
  72. if(elTooltipItemList[index].innerText.indexOf('习题')!= -1){
  73. continue;
  74. }
  75. // 判断是否是作业
  76. if(elTooltipItemList[index].innerText.indexOf('作业')!= -1){
  77. continue;
  78. }
  79. // 判断是否已过学习时间
  80. if (elTooltipItemList[index].children[1].children[0].innerText.indexOf("已过") != -1) {
  81. continue;
  82. }
  83. window.clearInterval(getElementInterval);
  84. GM_setValue("rowUrl", window.location.href.toString());
  85. // 网课页面跳转
  86. elTooltipItemList[index].click();
  87. window.close();
  88. break;
  89. }
  90. }
  91. }
  92. }, 1000);
  93.  
  94. let video;
  95. const videoPlay = setInterval(function () {
  96. // 获取播放器
  97. video = document.getElementsByClassName("xt_video_player")[0];
  98. if (!video) {
  99. return;
  100. }
  101. setTimeout(function () {
  102. // 视频开始1s之后再开启倍速
  103. speed()
  104. },1000);
  105. claim();
  106. window.clearInterval(videoPlay);
  107. }, 500);
  108.  
  109. // 是否播放完成的检测
  110. const playTimeOut = setInterval(function () {
  111. if (!video) {
  112. return;
  113. }
  114. video.play();
  115.  
  116. // 没有静音
  117. if (video.volume != 0) {
  118. claim();
  119. }
  120. const completeness = $(
  121. "#app > div.app-wrapper > div.wrap > div.viewContainer.heightAbsolutely > div > div.video-wrap > div > div > section.title > div.title-fr > div > div > span"
  122. );
  123. if (!completeness) {
  124. return;
  125. }
  126. if (typeof completeness[0] == "undefined") {
  127. return;
  128. }
  129. const videoText = completeness[0].innerHTML
  130. if (videoText) {
  131. let str = videoText.toString();
  132. const succ = str.substring(4, str.length - 1);
  133. const succNum = parseInt(succ);
  134. if (succ >= 95) {
  135. const url = GM_getValue("rowUrl");
  136. if(url){
  137. window.clearInterval(playTimeOut);
  138. window.location.replace(url);
  139. }
  140. }
  141. }
  142.  
  143. }, 1000);
  144.  
  145. // 是否为阅读类型
  146. const readInterval = setInterval(function () {
  147. const read = $(
  148. "#app > div.app-wrapper > div.wrap > div.viewContainer.heightAbsolutely > div > div.graph-wrap > div > div > section.title > div.title-fr > div > div"
  149. );
  150. if(!read){
  151. return
  152. }
  153. if (typeof read[0] == "undefined") {
  154. return;
  155. }
  156. const readText = read[0].innerHTML
  157. if(readText){
  158. if(readText.toString() === '已读'){
  159. window.clearInterval(readInterval);
  160. window.location.replace(GM_getValue("rowUrl"));
  161. }
  162. }
  163. }, 1000);
  164.  
  165. // 为了防止页面假死,定时刷新一下页面
  166. setTimeout(function () {
  167. // 如果保存了课程列表路径就回退的课程列表页面
  168. if(GM_getValue("rowUrl")){
  169. window.location.replace(GM_getValue("rowUrl"));
  170. }
  171. location.reload()
  172. },reloadTime * 60 * 1000);
  173. };
  174. })();

QingJ © 2025

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