升学e网通(EWT360)持续播放

新版升学e网通(EWT360)网页版自动不暂停

  1. // ==UserScript==
  2. // @name 升学e网通(EWT360)持续播放
  3. // @namespace https://space.bilibili.com/475523025
  4. // @version 2.2.5
  5. // @description 新版升学e网通(EWT360)网页版自动不暂停
  6. // @author 幻想一笑而过
  7. // @match https://teacher.ewt360.com/ewtbend/bend/index/*
  8. // @match https://web.ewt360.com/site-study/*
  9. // @icon data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMCAxMCIgY2xhc3M9ImRlc2lnbi1pY29uZm9udCI+CiAgPHBhdGggZD0iTTIsNCBDMi41NTIyODQ3NSw0IDMsNC40NDc3MTUyNSAzLDUgTDMsMTAgQzMsMTAuNTUyMjg0NyAyLjU1MjI4NDc1LDExIDIsMTEgQzEuNDQ3NzE1MjUsMTEgMSwxMC41NTIyODQ3IDEsMTAgTDEsNSBDMSw0LjQ0NzcxNTI1IDEuNDQ3NzE1MjUsNCAyLDQgWiBNNiw1IEM2LjU1MjI4NDc1LDUgNyw1LjQ0NzcxNTI1IDcsNiBMNywxMCBDNywxMC41NTIyODQ3IDYuNTUyMjg0NzUsMTEgNiwxMSBDNS40NDc3MTUyNSwxMSA1LDEwLjU1MjI4NDcgNSwxMCBMNSw2IEM1LDUuNDQ3NzE1MjUgNS40NDc3MTUyNSw1IDYsNSBaIE0xMCwxIEMxMC41NTIyODQ3LDEgMTEsMS40NDc3MTUyNSAxMSwyIEwxMSwxMCBDMTEsMTAuNTUyMjg0NyAxMC41NTIyODQ3LDExIDEwLDExIEM5LjQ0NzcxNTI1LDExIDksMTAuNTUyMjg0NyA5LDEwIEw5LDIgQzksMS40NDc3MTUyNSA5LjQ0NzcxNTI1LDEgMTAsMSBaIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgtMSAtMSkiIGZpbGw9IiM1QThCRkYiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPgo8L3N2Zz4K
  10. // @contributionURL https://afdian.net/a/Svip9
  11. // @contributionAmount 5
  12. // @compatible edge
  13. // @compatible chrome
  14. // @compatible firefox
  15. // @license GPL-3.0-only
  16. // @grant none
  17. // ==/UserScript==
  18.  
  19. (function() {
  20. 'use strict';
  21. var vacationURL="https://teacher.ewt360.com/ewtbend/bend/index/index.html#/homework/play-videos?courseId=" // 假期任务视频
  22. var normalVideoURL="https://web.ewt360.com/site-study/#/playVideo?courseId=" // E讲堂视频
  23. var id="";
  24. var testId="";
  25. let bURL="";
  26. let href="";
  27. let i=0;
  28. function waitForElementToDisplay(selector, time) {
  29. if(document.querySelector(selector)){
  30. setTimeout(function() {
  31. console.log(`${selector} 对象已出现`);
  32. bURL="";
  33. for(let j=0;j<vacationURL.length;j++){
  34. bURL+=location.href[j];
  35. }
  36. if(vacationURL==bURL){
  37. i=0;
  38. document.querySelector("#ewt-teacher-main-container > div > div").appendChild(document.querySelector("#ewt-teacher-main-container > div > div > div > div.play_video_main_content_box > div > div.course_package_right_container"))
  39. while(!document.querySelector("#vjs_video_"+i.toString())){
  40. i++;
  41. }
  42. id=i.toString();
  43. console.log("id = "+id);
  44. i=0;
  45. while(!document.querySelector("#rc-tabs-"+i.toString()+"-panel-1 > div > ul > div > li > div > div.course_chapter_btn_box > a > p")){
  46. if(i>1000)break;
  47. i++;
  48. }
  49. testId=i.toString();
  50. console.log("testId = "+testId);
  51. href=location.href;
  52. }else {
  53. bURL="";
  54. for(let j=0;j<normalVideoURL.length;j++){
  55. bURL+=location.href[j];
  56. }
  57. if(normalVideoURL==bURL){
  58. i=0;
  59. //document.querySelector("#root > div > div.play_video_main_box > div.play_video_main_content_box.W1200 > div.course_extrame").appendChild(document.querySelector("#root > div > div.play_video_main_box > div.play_video_main_content_box.W1200 > div.course_package_container > div.course_package_right_container"))
  60. while(!document.querySelector("#vjs_video_"+i.toString())){
  61. i++;
  62. }
  63. id=i.toString();
  64. console.log("id = "+id);
  65. href=location.href;
  66. }
  67. }
  68. return;
  69. }, 1200);
  70. }
  71. else {
  72. setTimeout(function() {
  73. waitForElementToDisplay(selector, time);
  74. }, time);
  75. }
  76. }
  77. for(let j=0;j<vacationURL.length;j++){
  78. bURL+=location.href[j];
  79. }
  80. console.log("判断链接:"+bURL);
  81. if(vacationURL==bURL){
  82. waitForElementToDisplay("#video_player_box",100);
  83. }else{
  84. bURL="";
  85. for(let j=0;j<normalVideoURL.length;j++){
  86. bURL+=location.href[j];
  87. }
  88. if(normalVideoURL==bURL){
  89. waitForElementToDisplay("#video_player_box",100);
  90. }
  91. }
  92. $("body").bind("keydown",function(e){
  93. e=window.event||e;
  94. //禁止空格键翻页
  95. if(event.keyCode==32){
  96. return false;
  97. }
  98. });
  99. var inClose = true;
  100. setInterval(function(){
  101. if(href!=location.href){
  102. console.log("页面变更");
  103. bURL="";
  104. for(let j=0;j<vacationURL.length;j++){
  105. bURL+=location.href[j];
  106. }
  107. console.log("判断链接:"+bURL);
  108. href=location.href;
  109. if(vacationURL==bURL){
  110. waitForElementToDisplay("#video_player_box",100);
  111. }else{
  112. bURL="";
  113. for(let j=0;j<normalVideoURL.length;j++){
  114. bURL+=location.href[j];
  115. }
  116. if(normalVideoURL==bURL){
  117. waitForElementToDisplay("#video_player_box",100);
  118. }
  119. }
  120. }
  121. if(document.querySelector("#earnest_check_unpass_play > p:nth-child(1) > img")){ // 被暂停
  122. document.querySelector("#earnest_check_unpass_play > p:nth-child(1) > img").click(); // 瞬间继续播放
  123. }
  124. if(document.querySelector("#vjs_video_"+id+" > div.video-interactive-layer > div > div > div.question-combition > div.skip-container > div.btn.action-skip")){ // 出现题目时
  125. document.querySelector("#vjs_video_"+id+" > div.video-interactive-layer > div > div > div.question-combition > div.skip-container > div.btn.action-skip").click(); // 果断跳过
  126. }
  127. if(inClose&&document.querySelector("#vjs_video_"+id+" > div.vjs-control-bar > button.vjs-play-control.vjs-control.vjs-button.vjs-paused.vjs-ended")){ // 视频播放完成
  128. console.log('视频播放完成');
  129. inClose = false;
  130. if(document.querySelector("#rc-tabs-"+testId+"-panel-1 > div > ul > div > li > div > div.course_chapter_btn_box > a > p")){
  131. console.log('打开练习')
  132. document.querySelector("#rc-tabs-"+testId+"-panel-1 > div > ul > div > li > div > div.course_chapter_btn_box > a > p").click(); // 如果有练习则打开练习界面
  133. window.location.href="https://www.ewt360.com/"; // 返回主页
  134. }else{
  135. console.log('返回主页')
  136. window.location.href="https://www.ewt360.com/"; // 返回主页
  137. }
  138. }
  139. for(let k=0;k<100;k++){
  140. if(document.querySelector("body > div:nth-child("+k.toString()+") > div > div.ant-modal-wrap > div > div.ant-modal-content > div")){ // 《一心多用》
  141. document.querySelector("body > div:nth-child("+k.toString()+") > div > div.ant-modal-wrap > div > div.ant-modal-content > div > div > div.ant-modal-confirm-btns > button").click(); // 关闭弹窗
  142. if(document.querySelector("#vjs_video_"+id+" > button"))document.querySelector("#vjs_video_"+id+" > button").click(); // 继续播放
  143. }
  144. }
  145. }, 10);
  146. })();