zzxonline

storehouse

Αυτός ο κώδικας δεν πρέπει να εγκατασταθεί άμεσα. Είναι μια βιβλιοθήκη για άλλους κώδικες που περιλαμβάνεται μέσω της οδηγίας meta // @require https://update.greasyfork.org/scripts/494937/1381736/zzxonline.js

  1. (function() {
  2. 'use strict';
  3. /* globals jQuery, $, waitForKeyElements */
  4.  
  5. unsafeWindow.GM_getValue = GM_getValue
  6. unsafeWindow.GM_xmlhttpRequest = GM_xmlhttpRequest
  7.  
  8. // 检查当前窗口是否为顶层窗口
  9. if (window.self !== window.top) {
  10. return; // 如果是顶层窗口,则不执行脚本
  11. }
  12.  
  13. if(window.location.href.split('/',4).toString() === 'https:,,newsso.shu.edu.cn,login'){
  14. return;
  15. }
  16.  
  17. var ddds3 = null;
  18. var addMessage = null;
  19.  
  20. let btn1=GM_registerMenuCommand ("\u4f5c\u8005\uff1a\ud83c\udf49\u897f\u74dc\u8981\u5927\u7684\ud83c\udf49", function(){
  21. confirm("Hello,\u611f\u8c22\u4f7f\u7528\ud83c\udf49\u897f\u74dc\u5237\u8bfe\u52a9\u624b\ud83c\udf49\uff01\u591a\u591a\u53cd\u9988\u54e6");
  22. GM_unregisterMenuCommand(btn1);
  23. }, "");
  24. let btn2=GM_registerMenuCommand ("\u4ed8\u8d39\u5185\u5bb9", function(){
  25. alert("\u9650\u65f6\u514d\u8d39\uff0c\u5168\u529b\u5f00\u53d1\u4e2d...");
  26. }, "p");
  27.  
  28. var chapterCount = 0;
  29. var chapterId = 1;
  30. var sectionCount = 0;
  31. var sectionId = 1;
  32. var search = null;
  33. var searchVD = null;
  34. var searchFC = null;
  35. let uL = null;
  36. var courseCount = 0;
  37. var courseIndex = 0;
  38.  
  39.  
  40. //----解决重复监听start----
  41. //视频组件
  42. var elevideo = null;
  43. //视频开始的公共方法
  44. var vdplay = null;
  45. //视频正在播放的公共方法
  46. var vdplaying = null;
  47. //视频暂停的公共方法
  48. var vdpause = null;
  49. //视频结束的公共方法
  50. var vdended = null;
  51. //监听音量的公共方法
  52. var vdvolume = null;
  53. //----解决重复监听end----
  54.  
  55. var isListening = false;
  56.  
  57. //-----添加监听start------
  58. function addLisenner() {
  59.  
  60. //获取播放器组件
  61. elevideo = document.getElementsByTagName("video")[0];
  62.  
  63. vdplay = function(){
  64. console.log("xigua:\u5f00\u59cb\u64ad\u653e");
  65. addMessage("xigua:\u5f00\u59cb\u64ad\u653e");
  66. };
  67. vdpause = function(){
  68. console.log("xigua:\u6682\u505c\u64ad\u653e");
  69. addMessage("xigua:\u6682\u505c\u64ad\u653e");
  70. setTimeout(function(){
  71. elevideo.play();
  72. },1500);
  73. };
  74. vdended = function(){
  75. console.log("xigua:结束播放");
  76. addMessage("xigua:结束播放");
  77. setTimeout(function(){
  78. let videoCount = document.querySelector("#app > div > div.polyv-playback-page-container > div.global-playback-wrapper-container > div > div.catalog-panel > div.live-video-list > div > div.el-scrollbar__wrap > div").childElementCount;
  79. studying(0,videoCount);
  80. },5000)
  81. };
  82. vdvolume = function(){
  83. if(elevideo.volume < 1 && elevideo.volume > 0){
  84. let vlum = elevideo.volume.toString();
  85. console.log("xigua:当前音量("+vlum.substring(2,4)+"%)");
  86. addMessage("xigua:当前音量("+vlum.substring(2,4)+"%)");
  87. }else if(elevideo.volume == 0){
  88. console.log("xigua:当前音量(0%)");
  89. addMessage("xigua:当前音量(0%)");
  90. }else{
  91. console.log("xigua:当前音量(100%)");
  92. addMessage("xigua:当前音量(100%)");
  93. }
  94. }
  95.  
  96. elevideo.addEventListener('play',vdplay);
  97. elevideo.addEventListener('playing',vdplaying);
  98. elevideo.addEventListener('pause',vdpause);
  99. elevideo.addEventListener('ended',vdended);
  100. elevideo.addEventListener('volumechange',vdvolume);
  101.  
  102. elevideo.volume = 0.1;
  103. setTimeout(function(){
  104. elevideo.play();
  105. },1000);
  106. }
  107. //-----添加监听end------
  108.  
  109. //-----移除监听start---
  110. function removeLisenner(){
  111. if(vdplay != null){
  112. elevideo.removeEventListener("play", vdplay);
  113. }
  114. if(vdplaying != null){
  115. elevideo.removeEventListener("playing", vdplaying);
  116. }
  117. if(vdpause != null){
  118. elevideo.removeEventListener("pause", vdpause);
  119. }
  120. if(vdended != null){
  121. elevideo.removeEventListener("ended", vdended);
  122. }
  123. if(vdended != null){
  124. elevideo.removeEventListener("ended", vdended);
  125. }
  126. if(vdvolume != null){
  127. elevideo.removeEventListener("volumechange",vdvolume);
  128. }
  129. }
  130. //-----移除监听end---
  131.  
  132.  
  133. search = function(){
  134. if(chapterId <= chapterCount){
  135. if(sectionId <= sectionCount){
  136. addMessage("\u5171"+chapterCount+"\u7ae0\uff0c\u5f53\u524d\u7b2c"+chapterId+"\u7ae0\u7b2c"+sectionId+"\u8282\uff0c\u5171"+sectionCount+"\u8282\u3002");
  137. var xxjd = document.getElementsByClassName("subject-catalog subject-catalog-new")[0].getElementsByTagName("li")[chapterId-1].getElementsByClassName("item current-hover")[sectionId-1].getElementsByClassName("iconfont m-right")[1].innerText;
  138. if(xxjd === '重新学习'){
  139. addMessage("\u7b2c"+chapterId+"\u7ae0\u7b2c"+sectionId+"\u8282\u5df2\u5b8c\u6210\uff0c\u68c0\u7d22\u4e0b\u4e00\u8282\u3002");
  140. sectionId++;
  141. search();
  142. }else{
  143. addMessage("\u7b2c"+chapterId+"\u7ae0\u7b2c"+sectionId+"\u8282\u672a\u5b8c\u6210\uff0c\u5373\u5c06\u8fdb\u5165\u5b66\u4e60\u3002");
  144. setTimeout(function(){
  145. document.getElementsByClassName("subject-catalog subject-catalog-new")[0].getElementsByTagName("li")[chapterId-1].getElementsByClassName("item current-hover")[sectionId-1].getElementsByClassName("iconfont m-right")[1].click();
  146. },1000);
  147. }
  148. }else{
  149. addMessage("\u5f53\u524d\u7ae0\u8282\u5df2\u5b8c\u6210\uff0c\u68c0\u7d22\u4e0b\u4e00\u7ae0\u3002");
  150. sectionId = 1;
  151. chapterId++;
  152. if(chapterId <= chapterCount){
  153. sectionCount = document.getElementsByClassName("subject-catalog subject-catalog-new")[0].getElementsByTagName("li")[chapterId-1].getElementsByClassName("item current-hover").length;
  154. }
  155. search();
  156. }
  157. }else{
  158. addMessage("\u5b66\u4e60\u5b8c\u6210\uff0c\u9000\u51fa\uff01");
  159. }
  160. }
  161.  
  162. searchVD = function(){
  163. if(document.getElementsByTagName('video')[0].ended){
  164. //总课程数
  165. courseCount = document.getElementsByClassName('new_bg').length;
  166. selectStudying(0,courseCount);
  167. }else{
  168. document.getElementsByTagName('video')[0].play();
  169. }
  170. }
  171.  
  172. const panel = function(){
  173. var container = $('<div id="gm-interface"></div>');
  174. var titleBar = $('<div id="gm-title-bar">\ud83c\udf49\u897f\u74dc\u7f51\u8bfe\u52a9\u624b\ud83c\udf49</div>');
  175. var minimizeButton = $('<div title="\u6536\u8d77" style="display:black"><svg id="gm-minimize-button" class="bi bi-dash-square" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M14 1H2a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1zM2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2z"/><path fill-rule="evenodd" d="M3.5 8a.5.5 0 0 1 .5-.5h8a.5.5 0 0 1 0 1H4a.5.5 0 0 1-.5-.5z"/></svg></div>');
  176. var maxButton = $('<div title="\u5c55\u5f00" style="display:none"><svg id="gm-minimize-button" class="bi bi-plus-square" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M8 3.5a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5H4a.5.5 0 0 1 0-1h3.5V4a.5.5 0 0 1 .5-.5z"/><path fill-rule="evenodd" d="M7.5 8a.5.5 0 0 1 .5-.5h4a.5.5 0 0 1 0 1H8.5V12a.5.5 0 0 1-1 0V8z"/><path fill-rule="evenodd" d="M14 1H2a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1zM2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2z"/></svg></div>');
  177. var content = $('<div id="gm-content"></div>');
  178. var tips = $('<div class="tip" style="display:none;">\u957f\u6309\u62d6\u62fd</div>');
  179. var scrollText = $('<marquee>').text('\u4e7e\u5764\u672a\u5b9a\uff0c\u4f60\u6211\u7686\u662f\u9ed1\u9a6c----\u4f5c\u8005\uff1a\u897f\u74dc\u8981\u5927\u7684\uff08\u611f\u8c22\u652f\u6301\uff01\uff09').css({
  180. 'position': 'absolute',
  181. 'top': '15%',
  182. 'left': '50%',
  183. 'transform': 'translate(-50%, -50%)',
  184. 'width': '90%',
  185. 'height': '25px',
  186. 'font-size': '16px',
  187. 'line-height': '1.5',
  188. 'white-space': 'nowrap'
  189. }).appendTo(content);
  190. //var ddds1 = $('<div style="position: absolute;top: 20%;width:90%;height:10%;padding: 3px;background: #ffedf0;border-radius: 5px;">\u70b9\u51fb\u542f\u52a8\uff1a<button id="startxg" style="position: absolute;width:48px;right: 10px;background-color: #ffe5e5;border-radius: 4px;border-color: #ffc0c0;color: grey;">\u542f\u52a8</button></div>');
  191. //var ddds5 = $('<div style="position: absolute;top: 35%;width:90%;height:10%;padding: 3px;background: #ffedf0;border-radius: 5px;">\u70b9\u51fb\u542f\u52a8\uff1a<button id="stopxg" style="position: absolute;width:48px;right: 10px;background-color: #ffe5e5;border-radius: 4px;border-color: #ffc0c0;color: grey;">暂停</button></div>');
  192. //var ddds2 = $('<div style="position: absolute;top: 50%;width:90%;height:10%;padding: 3px;background: #ffedf0;border-radius: 5px;">\u89c6\u9891\u500d\u901f\uff1a<button id="speedxg" style="position: absolute;width:48px;right: 10px;background-color: #ffe5e5;border-radius: 4px;border-color: #ffc0c0;color: grey;">X16</button></div>');
  193. ddds3 = $('<div id="message-container" style="position: absolute;display: grid;align-content: center;justify-content: center;top: 20%;width:94%;height:62%;max-height:62%;overflow-y:auto;padding: 3px;background: #ffffff;border-radius: 5px;"></div>');
  194. var ddds4 = $('<div style="position: absolute;top: 85%;width:94%;height:10%;padding: 3px;background: #ffedf0;border-radius: 5px;"><button id="deloldData" style="position: absolute;width:69px;right: 313px;background-color: #ffe5e5;border-radius: 4px;border-color: #ffc0c0;color: grey;">清空缓存</button><button id="beginExam" style="position: absolute;width:69px;right: 216px;background-color: #ffe5e5;border-radius: 4px;border-color: #ffc0c0;color: grey;">考试</button><a href="http://8.130.116.135/?article/" style="position: absolute;right: 10px;text-decoration: none;color: pink;">\u003e\u003e\u003e\u8054\u7cfb\u003a\u0031\u0039\u0030\u0038\u0032\u0034\u0035\u0033\u0030\u0032\u0040\u0071\u0071\u002e\u0063\u006f\u006d</a></div>');
  195.  
  196. container.append(titleBar);
  197. //content.append(ddds1);
  198. //content.append(ddds5);
  199. //content.append(ddds2);
  200. content.append(ddds3);
  201. content.append(ddds4);
  202. container.append(content);
  203. container.append(maxButton);
  204. container.append(minimizeButton);
  205. $('body').append(container);
  206. $('body').append(tips);
  207.  
  208. GM_addStyle(`
  209. #gm-interface {
  210. position: fixed;
  211. top: 10%;
  212. left: 70%;
  213. border-radius: 5px;
  214. background-color: white;
  215. z-index: 9999;
  216. }
  217.  
  218. #gm-title-bar {
  219. padding: 5px;
  220. background-color: #ffc0c0;
  221. border: 1px solid black;
  222. border-radius: 5px;
  223. cursor: grab;
  224. }
  225.  
  226. #gm-minimize-button {
  227. position: absolute;
  228. top: 2px;
  229. right: 2px;
  230. width: 30px;
  231. height: 30px;
  232. border-radius: 5px;
  233. padding: 0;
  234. font-weight: bold;
  235. background-color: #ffc0c0;
  236. cursor: pointer;
  237. }
  238.  
  239. #gm-content {
  240. padding: 10px;
  241. border: 1px solid black;
  242. border-radius: 2px 2px 5px 5px;
  243. background-color: #ffe5e5;
  244. width: 400px;
  245. height: 300px;
  246. }
  247. .tip{
  248. font-family: "黑体";
  249. color: black;
  250. -webkit-transform: scale(0.8);
  251. position:absolute;
  252. padding: 6px 5px;
  253. background-color:#ffe8f0;
  254. border-radius: 4px;
  255. z-index: 9999;
  256. }
  257. `);
  258.  
  259. titleBar.on('mousemove',function(e){
  260. tips.attr("style", "display:black;");
  261. var top = e.pageY+5;
  262. var left = e.pageX+5;
  263. tips.css({
  264. 'top' : top + 'px',
  265. 'left': left+ 'px'
  266. });
  267. });
  268.  
  269. titleBar.on('mouseout',function(){
  270. tips.hide();
  271. });
  272.  
  273. titleBar.on('mousedown', function(e) {
  274. var startX = e.pageX - container.offset().left + window.scrollX;
  275. var startY = e.pageY - container.offset().top + window.scrollY;
  276.  
  277. $(document).on('mousemove', function(e) {
  278. e.preventDefault();
  279. var newX = e.pageX - startX;
  280. var newY = e.pageY - startY;
  281. container.css({ left: newX, top: newY });
  282. });
  283.  
  284. $(document).on('mouseup', function() {
  285. $(document).off('mousemove');
  286. $(document).off('mouseup');
  287. });
  288. });
  289.  
  290. $("#deloldData").on('click',function(){
  291. ddds3.children().remove();
  292. // 获取所有存储的键
  293. // const keys = GM_listValues();
  294.  
  295. // 循环遍历并删除每个键值对
  296. // keys.forEach(key => {
  297. // GM_deleteValue(key);
  298. // });
  299. addMessage("已清空缓存");
  300. });
  301.  
  302. $("#beginExam").on('click',function(){
  303. ddds3.children().remove();
  304. if(window.location.href.split('/',8).toString() === 'https:,,www.learnin.com.cn,user,#,user,student,course'){
  305. let btn1 = document.querySelector("#app > div > div.page-student-course-topic-do-container > div.do-topic-header > div > div.function-btn.align-right").children[0].innerText;
  306. let btn2 = document.querySelector("#app > div > div.page-student-course-topic-do-container > div.do-topic-header > div > div.function-btn.align-right").children[1].innerText;
  307.  
  308. if(btn1 === '保存并离开' && btn2 === '提交作业'){
  309. addMessage("连接题库中...");
  310.  
  311.  
  312. examIndex = 0;
  313. if(document.querySelector("#app > div > div.page-student-course-topic-do-container > div.do-topic-body.store-topic > div > div > div.do-store-topic-content > div > div.group-item-body") != null){
  314. getTitle();
  315. examPageCount = document.querySelector("#app > div > div.page-student-course-topic-do-container > div.do-topic-body.store-topic > div > div > div.do-store-topic-content").childElementCount;
  316. examAllCount = document.querySelector("#app > div > div.page-student-course-topic-do-container > div.do-topic-body.store-topic > div > div > div.do-store-topic-content > div > div.group-item-body").childElementCount;
  317.  
  318. setTimeout(() => {
  319. addMessage("开始答题");
  320. toggleOverlay(true);
  321. beginExam();
  322. },1000);
  323. }else{
  324. getTitleEng();
  325. examAllCount = document.querySelector("#app > div > div.page-student-course-topic-do-container > div.do-topic-body.card-topic > div > div > div.student-topic-stem-sheet > div.topic-stem-sheet-text > div > div.el-scrollbar__wrap > div > div > div > div.answer-content-wrapper > div").childElementCount;
  326.  
  327. setTimeout(() => {
  328. addMessage("开始答题");
  329. toggleOverlay(true);
  330. beginExamEng();
  331. },1000);
  332. }
  333. }
  334. else{
  335. addMessage("此功能只在作业内生效");
  336. }
  337. }
  338. else{
  339. addMessage("此功能只在作业内生效");
  340. }
  341. });
  342.  
  343. minimizeButton.on('click', function() {
  344. minimizeButton.attr("style", "display:none;");
  345. maxButton.attr("style", "display:black;");
  346. content.slideToggle(0);
  347. container.css({ width: 200 });
  348. });
  349.  
  350. maxButton.on('click', function() {
  351. minimizeButton.attr("style", "display:black;");
  352. maxButton.attr("style", "display:none;");
  353. content.slideToggle(0);
  354. container.css({ width: 422 });
  355. });
  356.  
  357. ddds3.on('mousewheel', function(event) {
  358. event.preventDefault();
  359. var scrollTop = ddds3.scrollTop();
  360. ddds3.scrollTop(scrollTop + event.originalEvent.deltaY);
  361. });
  362.  
  363. addMessage = function(message){
  364. if (ddds3.children().length >= 288) {
  365. ddds3.children().first().remove();
  366. }
  367. var messageElement = $('<div class="message"></div>').text(message).css({
  368. 'margin-bottom': '10px'
  369. }).appendTo(ddds3);
  370. }
  371.  
  372. }
  373.  
  374. panel();
  375. addMessage("\u002d\u002d\u002d\u002d\u6b63\u5728\u542f\u52a8\uff0c\u8bf7\u7a0d\u540e\u002e\u002e\u002e\u002d\u002d\u002d\u002d");
  376.  
  377. var wait;
  378.  
  379. function startSetInt(){
  380. wait = setInterval(function (){
  381. ddds3.children().remove();
  382. // addMessage(window.location.href);
  383. if(window.location.href.split('/',4).toString() === 'https:,,newsso.shu.edu.cn,login'){
  384. try{
  385. addMessage("登录页,请登录");
  386. }catch(e){
  387. addMessage(e);
  388. addMessage("请登录");
  389. }
  390. }
  391. else if(window.location.href.split('/',5).toString() === 'https:,,www.icce.shu.edu.cn,Home,StudentIndex'){
  392. try{
  393. addMessage("首页,请前往课程信息");
  394. // window.open('https://cjxyol2.hebeinu.edu.cn/online/course/list','_blank');
  395. clearInterval(wait);
  396. }catch(e){
  397. addMessage(e);
  398. addMessage("请登录");
  399. }
  400. }
  401. else if(window.location.href.split('/',5).toString() === 'https:,,www.icce.shu.edu.cn,StudentPortal,StudentSchedule'){
  402. try{
  403. addMessage("课程表,请选择要学习的课程");
  404. clearInterval(wait);
  405. }catch(e){
  406. addMessage(e);
  407. addMessage("请登录");
  408. }
  409. }
  410. else if(window.location.href.split('/')[9] === 'space'){
  411. try{
  412.  
  413. addMessage("章节列表");
  414. let prHref = window.location.href;
  415. GM_setValue('prHref',prHref);
  416. document.querySelector("#courseSpaceStep2 > div:nth-child(1) > a").click();
  417.  
  418. setTimeout(function(){
  419. if(document.querySelector("#tab-finished") != null){
  420. document.querySelector("#tab-finished").click();
  421. setTimeout(function(){
  422. let liveCount = document.querySelector("#pane-finished").childElementCount;
  423.  
  424. serchLive(0,liveCount);
  425. },500);
  426. }
  427. else{
  428. document.querySelector("#app > div > div.page-student-course-space > div.page-header > div > div > div > div.track-wrap > div > div > div > div.logo-wrap > div.title.ellipsis").click();
  429. setTimeout(function(){
  430. document.querySelector("#courseSpaceStep4 > div.chapter-content > div > div.chapter-addition-statistics-to-study > a").click();
  431. },1500);
  432. }
  433. },500);
  434.  
  435. clearInterval(wait);
  436. }catch(e){
  437. addMessage(e);
  438. addMessage("...请登录");
  439. }
  440. }
  441. else if(window.location.href.split('/')[9] === 'learn'){
  442. try{
  443. addMessage("学习页");
  444. // chapterCount = document.querySelector("#resType2List > tbody").childElementCount - 1;
  445. if(document.getElementsByTagName('video')[0] === undefined){
  446. if(document.querySelector("#app > div > div.page-student-course-outline-learn > div.learn-body > div.learn-main-content").children[0].className === 'layout-hint-index'){
  447. addMessage("前往下一节");
  448. document.querySelector("#app > div > div.page-student-course-outline-learn > div.learn-header > div.nav-btn > div.next-chapter.align-right > button").click();
  449. }
  450. else if(document.querySelector("#app > div > div.page-student-course-outline-learn > div.learn-body > div.learn-main-content > div > div.layout-body > div > div.cont-box > div > div.section-content-addition-document-preview-live-done > div.common-course-live-play-back > div > button") != null){
  451. addMessage("直播回回放");
  452. // document.querySelector("#app > div > div.page-student-course-outline-learn > div.learn-body > div.learn-main-content > div > div.layout-body > div > div.cont-box > div > div.section-content-addition-document-preview-live-done > div.common-course-live-play-back > div > button").click();
  453. document.querySelector("#app > div > div.page-student-course-outline-learn > div.learn-header > div.nav-btn > div.next-chapter.align-right > button").click();
  454. }
  455. else{
  456. addMessage("PPT与作业");
  457. setTimeout(function(){
  458. document.querySelector("#app > div > div.page-student-course-outline-learn > div.learn-header > div.nav-btn > div.next-chapter.align-right > button").click();
  459. },3000);
  460. }
  461. }else{
  462. studyingPage();
  463. clearInterval(wait);
  464. }
  465. }catch(e){
  466. addMessage(e);
  467. addMessage("请登录");
  468. }
  469. }
  470. else if(window.location.href.split('/')[9] === 'polyvCoursePlayBack'){
  471. try{
  472. addMessage("直播回放");
  473. let videoCount = document.querySelector("#app > div > div.polyv-playback-page-container > div.global-playback-wrapper-container > div > div.catalog-panel > div.live-video-list > div > div.el-scrollbar__wrap > div").childElementCount;
  474. studying(0,videoCount);
  475. clearInterval(wait);
  476. }catch(e){
  477. addMessage(e);
  478. addMessage("请登录");
  479. }
  480. }
  481. else if(window.location.href.split('/',8).toString() === 'https:,,www.learnin.com.cn,user,#,user,student,course'){
  482. try{
  483. let btn1 = document.querySelector("#app > div > div.page-student-course-topic-do-container > div.do-topic-header > div > div.function-btn.align-right").children[0].innerText;
  484. let btn2 = document.querySelector("#app > div > div.page-student-course-topic-do-container > div.do-topic-header > div > div.function-btn.align-right").children[1].innerText;
  485.  
  486. if(btn1 === '保存并离开' && btn2 === '提交作业'){
  487. addMessage("连接题库中...");
  488.  
  489.  
  490. examIndex = 0;
  491. if(document.querySelector("#app > div > div.page-student-course-topic-do-container > div.do-topic-body.store-topic > div > div > div.do-store-topic-content > div > div.group-item-body") != null){
  492. getTitle();
  493. examPageCount = document.querySelector("#app > div > div.page-student-course-topic-do-container > div.do-topic-body.store-topic > div > div > div.do-store-topic-content").childElementCount;
  494. examAllCount = document.querySelector("#app > div > div.page-student-course-topic-do-container > div.do-topic-body.store-topic > div > div > div.do-store-topic-content > div > div.group-item-body").childElementCount;
  495.  
  496. setTimeout(() => {
  497. addMessage("开始答题");
  498. toggleOverlay(true);
  499. beginExam();
  500. },1000);
  501. }else{
  502. getTitleEng();
  503. examPageCount = document.querySelector("#app > div > div.page-student-course-topic-do-container > div.do-topic-body.store-topic > div > div > div.do-store-topic-content").childElementCount;
  504.  
  505. examAllCount = document.querySelector("#app > div > div.page-student-course-topic-do-container > div.do-topic-body.card-topic > div > div > div.student-topic-stem-sheet > div.topic-stem-sheet-text > div > div.el-scrollbar__wrap > div > div > div > div.answer-content-wrapper > div").childElementCount;
  506.  
  507. setTimeout(() => {
  508. addMessage("开始答题(ENG)");
  509. toggleOverlay(true);
  510. beginExamEng();
  511. },1000);
  512. }
  513. }
  514. if(btn1 === '关闭' && btn2 === '继续答题' || btn2 === '重新答题'){
  515. addMessage("错题页");
  516. addMessage("连接题库中,请稍后...");
  517. setTimeout(() => {
  518. toggleOverlay(true);
  519. getAnswer();
  520. },1000);
  521. }
  522.  
  523. clearInterval(wait);
  524. }catch(e){
  525. addMessage(e);
  526. addMessage("请登录");
  527. }
  528. }
  529. else{
  530. addMessage("请登录");
  531. }
  532. }, 3698);
  533. }
  534.  
  535. startSetInt();
  536.  
  537. function serchLive(index,count){
  538. if(index < count){
  539. let tableCount = document.querySelector("#pane-finished").children[index].children[1].children[0].childElementCount;
  540. let btnClassName = document.querySelector("#pane-finished").children[index].children[1].children[1].getElementsByTagName('button')[0].className;
  541. if(tableCount < 2 && btnClassName != 'el-button live-play-back-disabled-btn el-button--primary el-button--small is-round'){
  542. let titleLive = document.querySelector("#pane-finished").children[index].children[0].children[0].innerText;
  543. addMessage(titleLive);
  544. setTimeout(function(){
  545. document.querySelector("#pane-finished").children[index].children[1].children[1].getElementsByTagName('button')[0].click();
  546. addMessage("5秒后关闭窗口");
  547. setTimeout(function(){
  548. window.close();
  549. },3000);
  550. },1000);
  551. }
  552. else{
  553. serchLive(++index,count);
  554. }
  555. }
  556. else{
  557. addMessage("直播学习完毕");
  558. document.querySelector("#app > div > div.page-student-course-space > div.page-header > div > div > div > div.track-wrap > div > div > div > div.logo-wrap > div.title.ellipsis").click();
  559. setTimeout(function(){
  560. document.querySelector("#courseSpaceStep4 > div.chapter-content > div > div.chapter-addition-statistics-to-study > a").click();
  561. },1500);
  562. }
  563. }
  564.  
  565. function studying(index,count){
  566. if(index < count){
  567. let vdStatu = document.querySelector("#app > div > div.polyv-playback-page-container > div.global-playback-wrapper-container > div > div.catalog-panel > div.live-video-list > div > div.el-scrollbar__wrap > div").children[index].children[1].className;
  568. if(vdStatu != 'video-playback-state done'){
  569. document.querySelector("#app > div > div.polyv-playback-page-container > div.global-playback-wrapper-container > div > div.catalog-panel > div.live-video-list > div > div.el-scrollbar__wrap > div").children[index].children[2].click();
  570. setTimeout(function(){
  571. if(document.getElementsByTagName('video')[0] != undefined){
  572. removeLisenner();
  573. addLisenner();
  574. }
  575. },1000);
  576. }
  577. else{
  578. studying(++index,count)
  579. }
  580. }
  581. else{
  582. addMessage("直播回放完成");
  583. window.open(GM_getValue('prHref'),'_self');
  584. setTimeout(function(){
  585. window.location.reload();
  586. },2000);
  587. }
  588.  
  589. }
  590.  
  591. function studyingPage(){
  592. let stu1 = document.querySelector("#app > div > div.page-student-course-outline-learn > div.learn-body > div.learn-main-content > div > div.layout-body > div > div.cont-box > div > div > div.video-hint > div:nth-child(2)").getElementsByTagName('span')[1].innerText;
  593. let stu2 = document.querySelector("#app > div > div.page-student-course-outline-learn > div.learn-body > div.learn-main-content > div > div.layout-body > div > div.cont-box > div > div > div.video-hint > div:nth-child(2)").getElementsByTagName('span')[2].innerText;
  594. let cName = document.querySelector("#app > div > div.page-student-course-outline-learn > div.learn-header > div.chapter-section-title.ellipsis > span").innerText;
  595. if(stu1 <= stu2){
  596. addMessage(cName+"|学习完成");
  597. setTimeout(function(){
  598. document.querySelector("#app > div > div.page-student-course-outline-learn > div.learn-header > div.nav-btn > div.next-chapter.align-right > button").click();
  599. startSetInt();
  600. },800)
  601. }
  602. else{
  603. addMessage(cName+"|学习未完成");
  604. setTimeout(function(){
  605. removeLisenner();
  606. addLisenner();
  607. },3689);
  608. }
  609. }
  610.  
  611. var parser = new DOMParser();
  612. function getStatus(){
  613. let ul = window.location.href;
  614. GM_xmlhttpRequest({
  615. url: ul,
  616. method: "GET",
  617. Cookie: '',
  618. onload: function(response) {
  619. let htmlDoc = parser.parseFromString(response.responseText, 'text/html');
  620. let targetElement = htmlDoc.querySelector('#resType2List > tbody').children[chapterId].children[3].innerText;
  621. console.log(targetElement);
  622. let st = parseInt(targetElement);
  623. if(st >= 100){
  624. window.location.reload();
  625. }else{
  626. setTimeout(function(){
  627. studyStatus();
  628. },5000);
  629. }
  630. }
  631. })
  632. }
  633.  
  634. var overlay = null;
  635. function toggleOverlay(show) {
  636. if (show) {
  637. overlay = document.createElement('div');
  638. overlay.style.position = 'fixed';
  639. overlay.style.top = '0';
  640. overlay.style.left = '0';
  641. overlay.style.width = '100%';
  642. overlay.style.height = '100%';
  643. overlay.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
  644. overlay.style.zIndex = '9999';
  645.  
  646. overlay.addEventListener('click', function(event) {
  647. event.stopPropagation();
  648. event.preventDefault();
  649. });
  650.  
  651. document.body.appendChild(overlay);
  652. } else {
  653. if (overlay) {
  654. overlay.parentNode.removeChild(overlay);
  655. overlay = null;
  656. }
  657. }
  658. }
  659.  
  660. function getAnswer(){
  661. $.ajax({
  662. url: 'https://www.learnin.com.cn/app/user/student/course/space/topic/appStudentCourseTopic/loadTopicData',
  663. method: 'POST',
  664. data: {'courseId': window.location.href.split('/')[8],'topicId': window.location.href.split('/')[10]},
  665. beforeSend: function(xhr) {
  666. xhr.setRequestHeader("Authorization", "Bearer " + document.cookie.replace(/(?:(?:^|.*;\s*)accessToken\s*\=\s*([^;]*).*$)|^.*$/, "$1"));
  667. },
  668. Cookie: document.cookie,
  669. success: function(response){
  670. let awRes = JSON.parse(response).topic.topicItems;
  671. console.log(awRes);
  672. let timeWait = 1000 * 2;
  673. if(awRes.length > 6){
  674. timeWait = 1000 * 3;
  675. }
  676.  
  677. for(let i=0; i<awRes.length; i++){
  678. if(!awRes[i].childList){
  679. awRes.forEach(obj => {
  680. console.log(obj.id);
  681. saveAnswer(obj.id,obj.answer);
  682. });
  683. }else{
  684. awRes[i].childList.forEach(obj => {
  685. console.log(obj.questionTitle);
  686. saveAnswer(obj.questionTitle,obj.optionList);
  687. });
  688. }
  689. }
  690. setTimeout(function(){
  691. toggleOverlay(false);
  692. addMessage('题库加载完毕');
  693. addMessage('1.点击‘继续作答’刷新试卷。2.点击‘考试’开始答题');
  694. },timeWait);
  695. },
  696. error: function(){
  697. console.log('题库加载失败');
  698. }
  699. })
  700. }
  701.  
  702. function getTitleEng(){
  703. $.ajax({
  704. url: 'https://www.learnin.com.cn/app/user/student/course/space/topic/appStudentCourseTopic/loadRedoTopicData',
  705. method: 'POST',
  706. data: {'courseId': window.location.href.split('/')[8],'topicId': window.location.href.split('/')[10]},
  707. beforeSend: function(xhr) {
  708. xhr.setRequestHeader("Authorization", "Bearer " + document.cookie.replace(/(?:(?:^|.*;\s*)accessToken\s*\=\s*([^;]*).*$)|^.*$/, "$1"));
  709. },
  710. Cookie: document.cookie,
  711. success: function(response){
  712. let awRes = JSON.parse(response).topic.topicItems;
  713. console.log(awRes);
  714. questionTitleList = awRes;
  715. },
  716. error: function(){
  717. console.log('题库加载失败');
  718. }
  719. })
  720. }
  721.  
  722. function getTitle(page = 0){
  723. $.ajax({
  724. url: 'https://www.learnin.com.cn/app/user/student/course/space/topic/appStudentCourseTopic/loadRedoTopicData',
  725. method: 'POST',
  726. data: {'courseId': window.location.href.split('/')[8],'topicId': window.location.href.split('/')[10]},
  727. beforeSend: function(xhr) {
  728. xhr.setRequestHeader("Authorization", "Bearer " + document.cookie.replace(/(?:(?:^|.*;\s*)accessToken\s*\=\s*([^;]*).*$)|^.*$/, "$1"));
  729. },
  730. Cookie: document.cookie,
  731. success: function(response){
  732. let awRes = JSON.parse(response).topic.topicItems[page].childList;
  733. console.log(awRes);
  734. questionTitleList = awRes;
  735. },
  736. error: function(){
  737. console.log('题库加载失败');
  738. }
  739. })
  740. }
  741.  
  742. function getLocalAnswer(){
  743. let oldData = GM_getValue('answerList');
  744. if (Array.isArray(oldData)) {
  745. return oldData;
  746. }
  747. return [];
  748. }
  749.  
  750.  
  751. function saveAnswer(qT,qL){
  752. let answerList = getLocalAnswer();
  753. let juge = answerList.some(obj => obj.hasOwnProperty(qT));
  754.  
  755. if (juge) {
  756. console.log("答案已存在",qT);
  757. return false;
  758. }
  759.  
  760. let tempMap = {};
  761. tempMap[qT] = qL;
  762.  
  763. answerList.push(tempMap);
  764.  
  765. console.log("保存答案",qT);
  766.  
  767. GM_setValue('answerList',answerList);
  768.  
  769. return true;
  770. }
  771.  
  772. var radioIndex = 0;
  773. var checkboxIndex = 0;
  774. var radioCount = 0;
  775. var checkboxCount = 0;
  776. var examIndex = 0;
  777. var examAllCount = 0;
  778. var examPageIndex = 0;
  779. var examPageCount = 0;
  780. var questionTitleList;
  781.  
  782. function beginExamEng(){
  783. let asLocal = getLocalAnswer();
  784.  
  785. if(examIndex < examAllCount){
  786. let qusTitle = questionTitleList[examIndex].id;
  787.  
  788. let result = asLocal.reduce((accumulator, obj) => {
  789. if (qusTitle in obj) {
  790. return obj[qusTitle];
  791. }
  792. return accumulator;
  793. }, undefined);
  794.  
  795. console.log('result1',result,examIndex);
  796.  
  797. if (result !== undefined) {
  798.  
  799. addMessage('onlineDATA:'+result);
  800.  
  801. isTrueAnswerEng(0,result.length,result);
  802.  
  803. } else {
  804.  
  805. addMessage('result---undefind');
  806. let randomIndex = Math.floor(Math.random() * 4);
  807. document.querySelector("#app > div > div.page-student-course-topic-do-container > div.do-topic-body.card-topic > div > div > div.student-topic-stem-sheet > div.topic-stem-sheet-text > div > div.el-scrollbar__wrap > div > div > div > div.answer-content-wrapper > div").children[examIndex].children[0].children[1].children[randomIndex].click();
  808. examIndex++;
  809. setTimeout(function(){
  810. beginExamEng();
  811. },100);
  812. }
  813. }else{
  814. console.log("答题结束");
  815. // ddds3.children().remove();
  816. addMessage("已完成答题,请提交");
  817. console.log('asLocal',asLocal);
  818. toggleOverlay(false);
  819. }
  820. }
  821.  
  822. function beginExam(){
  823. let asLocal = getLocalAnswer();
  824.  
  825. if(examIndex < examAllCount){
  826. let qusTitle = questionTitleList[examIndex].questionTitle;
  827.  
  828. let result = asLocal.reduce((accumulator, obj) => {
  829. if (qusTitle in obj) {
  830. return obj[qusTitle];
  831. }
  832. return accumulator;
  833. }, undefined);
  834.  
  835. console.log('result1',result,examIndex);
  836.  
  837. if (result !== undefined) {
  838.  
  839. addMessage('onlineDATA:'+result);
  840.  
  841. isTrueAnswer(0,result.length,result);
  842. // inputRadio(0,result.length,result);
  843. // examIndex++;
  844. // beginExam();
  845. } else {
  846.  
  847. addMessage('result---undefind');
  848. document.querySelector("#app > div > div.page-student-course-topic-do-container > div.do-topic-body.store-topic > div > div > div.do-store-topic-content").children[examPageIndex].getElementsByClassName('store-question-item-container')[examIndex].getElementsByClassName('question-option-list')[0].children[1].children[0].click();
  849. examIndex++;
  850. setTimeout(function(){
  851. beginExam();
  852. },100);
  853. }
  854. }else{
  855. examPageIndex++;
  856. if(examPageIndex < examPageCount){
  857. getTitle(examPageIndex);
  858. examIndex = 0;
  859. examAllCount = document.querySelector("#app > div > div.page-student-course-topic-do-container > div.do-topic-body.store-topic > div > div > div.do-store-topic-content").children[examPageIndex].children[1].childElementCount;
  860. setTimeout(() => {
  861. beginExam();
  862. },1000);
  863. }
  864. else{
  865. console.log("答题结束");
  866. // ddds3.children().remove();
  867. addMessage("已完成答题,请提交");
  868. console.log('asLocal',asLocal);
  869. toggleOverlay(false);
  870. }
  871. }
  872. }
  873.  
  874. function isTrueAnswerEng(index,count,answerList){
  875. if(index < count){
  876.  
  877. inputRadioEng(answerList[index]);
  878.  
  879. setTimeout(function(){
  880. isTrueAnswerEng(++index,count,answerList);
  881. },200);
  882. }
  883. else{
  884. addMessage("ok");
  885. examIndex++;
  886. setTimeout(function(){
  887. beginExamEng();
  888. },200);
  889. }
  890. }
  891.  
  892. function isTrueAnswer(index,count,answerList){
  893. if(index < count){
  894.  
  895. if(answerList[index].isAnswer){
  896.  
  897. inputRadio(index);
  898.  
  899. setTimeout(function(){
  900. isTrueAnswer(++index,count,answerList);
  901. },200);
  902.  
  903. }
  904. else{
  905. isTrueAnswer(++index,count,answerList);
  906. }
  907.  
  908. }
  909. else{
  910. addMessage("ok");
  911. examIndex++;
  912. setTimeout(function(){
  913. beginExam();
  914. },200);
  915. }
  916. }
  917.  
  918. function inputRadioEng(index){
  919. switch(index)
  920. {
  921. case 'A':
  922. console.log("第"+(examIndex+1)+"题选","A");
  923. radioOkEng(0)
  924. break;
  925. case 'B':
  926. console.log("第"+(examIndex+1)+"题选","B");
  927. radioOkEng(1)
  928. break;
  929. case 'C':
  930. console.log("第"+(examIndex+1)+"题选","C");
  931. radioOkEng(2)
  932. break;
  933. case 'D':
  934. console.log("第"+(examIndex+1)+"题选","D");
  935. radioOkEng(3)
  936. break;
  937. case 'E':
  938. console.log("第"+(examIndex+1)+"题选","E");
  939. radioOkEng(4)
  940. break;
  941. }
  942. }
  943.  
  944. function inputRadio(index){
  945. switch(index)
  946. {
  947. case 0:
  948. console.log("第"+(examIndex+1)+"题选","A");
  949. radioOk(0)
  950. break;
  951. case 1:
  952. console.log("第"+(examIndex+1)+"题选","B");
  953. radioOk(1)
  954. break;
  955. case 2:
  956. console.log("第"+(examIndex+1)+"题选","C");
  957. radioOk(2)
  958. break;
  959. case 3:
  960. console.log("第"+(examIndex+1)+"题选","D");
  961. radioOk(3)
  962. break;
  963. case 4:
  964. console.log("第"+(examIndex+1)+"题选","E");
  965. radioOk(4)
  966. break;
  967. }
  968. }
  969.  
  970. function radioOkEng(index){
  971. if(document.querySelector("#app > div > div.page-student-course-topic-do-container > div.do-topic-body.card-topic > div > div > div.student-topic-stem-sheet > div.topic-stem-sheet-text > div > div.el-scrollbar__wrap > div > div > div > div.answer-content-wrapper > div").children[examIndex].children[0].children[1].children[index].className != 'topic-answer-option-tag selected'){
  972. document.querySelector("#app > div > div.page-student-course-topic-do-container > div.do-topic-body.card-topic > div > div > div.student-topic-stem-sheet > div.topic-stem-sheet-text > div > div.el-scrollbar__wrap > div > div > div > div.answer-content-wrapper > div").children[examIndex].children[0].children[1].children[index].click();
  973. }
  974. }
  975.  
  976. function radioOk(index){
  977. if(document.querySelector("#app > div > div.page-student-course-topic-do-container > div.do-topic-body.store-topic > div > div > div.do-store-topic-content").children[examPageIndex].getElementsByClassName('store-question-item-container')[examIndex].getElementsByClassName('question-option-list')[0].children[1].children[0].className != 'option-index active can-do'){
  978. document.querySelector("#app > div > div.page-student-course-topic-do-container > div.do-topic-body.store-topic > div > div > div.do-store-topic-content").children[examPageIndex].getElementsByClassName('store-question-item-container')[examIndex].getElementsByClassName('question-option-list')[0].children[index].children[0].click();
  979. }
  980. }
  981.  
  982. })();