师学通-平江县中小学教师信息技术2.0-代刷

自动换课|自动学习|刷课VX:shuake345

  1. // ==UserScript==
  2. // @name 师学通-平江县中小学教师信息技术2.0-代刷
  3. // @namespace 刷课V软件定制:vx,shuake345
  4. // @version 0.3
  5. // @description 自动换课|自动学习|刷课VX:shuake345
  6. // @author 刷课VX:shuake345
  7. // @match *://*.stu.teacher.com.cn/course/*
  8. // @match *://*.stu.teacher.com.cn/studyPlan*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. //'use strict';
  14. var timeneed
  15.  
  16. document.addEventListener("visibilitychange", function() {
  17. console.log(document.visibilityState);
  18. if(document.visibilityState == "hidden") {
  19. console.log('隐藏');
  20.  
  21. } else if (document.visibilityState == "visible") {
  22. if(document.URL.search('pointView')>1){
  23. sx()
  24. }
  25. if(document.URL.search('list')>1){
  26. setTimeout(gb,1242)
  27. }
  28.  
  29. }
  30. });
  31. function fh() {
  32. window.history.go(-1)
  33. }
  34. function gb(){
  35. window.close()
  36. }
  37.  
  38. function sx() {
  39. window.location.reload()
  40. }
  41.  
  42. function sleep(time) {
  43. return new Promise((resolve) => setTimeout(resolve, time));
  44. }
  45.  
  46. function shutdownTab(){
  47. window.opener=null;
  48. window.open('','_self');
  49. window.close();
  50. }
  51.  
  52. function insertLogoAndTextAfter(cssSelector, text){
  53. if (!document.querySelector("#yxwfz-logo")) {
  54. } else {
  55. document.querySelector("#yxwfz-text").innerHTML = text;
  56. }
  57. }
  58.  
  59. function getCoursesListGoal() {
  60. if (document.querySelectorAll("em").length) {
  61. return parseInt(document.querySelectorAll("em")[0].innerText.match(/\d+(?=分钟)/)) - parseInt(
  62. document.querySelectorAll("em")[1].innerText.match(/\d+(?=分钟)/)[0]);
  63. } else {
  64. return 300;
  65. }
  66. }
  67.  
  68. function getCourseProgress(courseDivItem) {
  69. if (courseDivItem.firstElementChild.lastElementChild.className == "item-infos pass") {
  70. return 1;
  71. } else if (courseDivItem.firstElementChild.lastElementChild.lastElementChild.childElementCount ==
  72. 1) {
  73. return 0;
  74. } else {
  75. return 0.01 * parseInt(courseDivItem.firstElementChild.lastElementChild.lastElementChild
  76. .lastElementChild.innerText.match(/\d+(?=%)/)[0]);
  77. }
  78. }
  79.  
  80. async function courseList() {
  81. await sleep(500);
  82. //课程选择
  83. let minutesTotal = getCoursesListGoal();
  84. document.querySelector("ul.filter-data > li:nth-child(3) > div > div.content > div:nth-child(3) > span").click();
  85. await sleep(500);
  86. if (document.querySelectorAll("div.item").length == 0) {
  87. document.querySelector("ul.filter-data > li:nth-child(3) > div > div.content > div:nth-child(1) > span").click();
  88. }
  89. await sleep(500);
  90. let courses = document.querySelectorAll("div.item");
  91. if (minutesTotal > 0) {
  92. console.log("目标学时:" + minutesTotal +"分钟");
  93. // 插入辅助标识
  94. insertLogoAndTextAfter("p.title > span","目标:" + minutesTotal +"分钟");
  95. for (var i = 0; i < courses.length; i++) {
  96. let jindubi = getCourseProgress(courses[i]);
  97. let minutes = (1 - jindubi) * parseInt(courses[i].firstElementChild.firstElementChild.lastElementChild
  98. .innerText.match(/\d+(?=分钟)/)[0]);
  99. minutes = minutes < minutesTotal ? minutes : minutesTotal;
  100. if (jindubi == 1) {
  101. continue;
  102. } else {
  103. courses[i].firstChild.firstChild.click();
  104. setTimeout(gb, minutes * 60 * 1000);
  105. insertLogoAndTextAfter("p.title > span","已打开第" + (i + 1) + "个课程,将在<span id = yxwfz-minutes>" + minutes.toFixed(2) + "</span>分钟后关闭");
  106. function countMinute() {
  107. document.querySelector("#yxwfz-minutes").innerText = minutes.toFixed(2);
  108. minutes = minutes - 1;
  109. setTimeout(countMinute, 60 * 1000);
  110. }
  111. countMinute();
  112. break;
  113. }
  114. }
  115. } else {
  116. }
  117. }
  118.  
  119. function kanke() {
  120.  
  121. // 插入辅助标识
  122. insertLogoAndTextAfter("span.icon.primary","");
  123.  
  124. //处理播放器事件
  125. if (document.querySelector("video")) {
  126. let playerH5 = document.querySelector("video");
  127. playerH5.volume = 0; //不想听声音
  128. if (playerH5.paused) {
  129. playerH5.play(); //不要暂停,播下去
  130. }
  131. }
  132.  
  133. //处理各种突发事件
  134. if (document.querySelector("div.ended-mask").style.display == "") {
  135. if (document.querySelector("p.next")){
  136. document.querySelector("p.next").click();
  137. console.log("一个看完,看下一个内容");
  138. document.querySelector("#yxwfz-text").innerText = "一个看完,看下一个内容";
  139. } else {
  140. console.log("播放完毕,即将关闭页面");
  141. document.querySelector("#yxwfz-text").innerText = "播放完毕,即将关闭页面";
  142. shutdownTab();
  143. }
  144. }
  145. if (document.querySelector("div.alarmClock-wrapper").style.display == "") {
  146. document.querySelector("div.alarmClock-wrapper").click();
  147. console.log("点继续看课");
  148. document.querySelector("#yxwfz-text").innerText = "点继续看课";
  149. }
  150. if (document.querySelector("div.scoring-wrapper").style.display == "") {
  151. document.querySelector('div.commit > button.ivu-btn').disabled=false;
  152. document.querySelector('div.commit > button.ivu-btn').click();
  153. console.log("给老师评价");
  154. document.querySelector("#yxwfz-text").innerText = "给老师评价";
  155. }
  156. if (document.querySelectorAll("button.ivu-btn.ivu-btn-text").length == 2) {
  157. document.querySelectorAll("button.ivu-btn.ivu-btn-text")[1].click();
  158. console.log("打开了其他播放页面,即将关闭本页面");
  159. document.querySelector("#yxwfz-text").innerText = "打开了其他播放页面,即将关闭本页面";
  160. }
  161. if (document.querySelector(".state > span").innerText.match(/您已完成看课总时长/)) {
  162. console.log("课时已达成,即将关闭页面");
  163. document.querySelector("#yxwfz-text").innerText = "课时已达成,即将关闭页面";
  164. shutdownTab();
  165. }
  166. //检测运行是否良好
  167. document.querySelector("#yxwfz-text").innerText = document.querySelector(".state > span").innerText;
  168. }
  169.  
  170. function start() {
  171. //判断是哪个页面
  172. if (location.pathname=="/train/guide/course/list") {
  173. courseList();
  174. } else if (location.pathname.match(/\/grain\/course\/\d*\/detail/)) {
  175. setInterval(kanke, 5000);
  176. } else {
  177. setTimeout(start,10000);
  178. }
  179. }
  180.  
  181. console.log("脚本加载正常");
  182. setTimeout(start, 3000);
  183. function zy(){
  184. if(document.URL.search('pointView')>1){
  185. var xialaanniu=document.querySelectorAll('[class="task-btns"]')
  186. for (var i=0;i<xialaanniu.length;i++){
  187. xialaanniu[i].click()
  188. }
  189. setTimeout(xuanzheshijian,2415)
  190. }
  191. }
  192. setTimeout(zy,5424)
  193. function xuanzheshijian(){//dianji
  194. var anniu=document.querySelectorAll('[class="num"]')
  195. for (var i=0;i<anniu.length;i++){
  196. if(anniu[i].innerText== "开始学习"){//已看时间<120分钟
  197. if(parseInt(anniu[i].offsetParent.previousElementSibling.innerText.replace(/[^\d]/g,'')) <timeneed){
  198. anniu[i].click()
  199. break;
  200. }
  201. }
  202. }
  203. }
  204.  
  205. function sy(){
  206. if(document.URL.search('courseSourceId')>1){
  207. if(document.querySelector('div.action-timer>span>span').innerText.search('已完成看')>0){
  208. setTimeout(gb,1242)
  209. }
  210. }
  211. }
  212. setInterval(sy,15424)
  213.  
  214. })();

QingJ © 2025

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