// ==UserScript== // @name 学习中心自动学习脚本 // @description Learning Center Automation Tools // @version 1.2 // @description 个人脚本 // @author leibing // @match *://yxgf.21tb.com/* // @icon https://21tb-file5.21tb.com/sf-server/file/getFile/faea6060ff41010e29235a87b176ff3e-N_1523333333333/60af80f6a3102fedcd26bc80_0100 // @require https://code.jquery.com/jquery-2.1.4.min.js // @grant none // @license MIT // @namespace https://greasyfork.org/users/1417023 // @downloadURL none // ==/UserScript== (function() { 'use strict'; function study() { //检测并发异常 var error_tips = document.querySelector(".error_tips") if(error_tips != null){ // 刷新页面 msg("刷新"); //document.location.reload(); return; } //课程类型一:单一课程类型 var cl_head_tip = document.querySelector(".cl-head-tip") if(cl_head_tip != null){ if (cl_head_tip.innerText.indexOf("已学习") > 0) { cl_head_tip.click(); msg("学习中"); return; } else{ msg("学习完成" , cl_head_tip.innerText) clearInterval(intervalId); return; } } //课程类型二:课程列表类型 var section_item = document.querySelectorAll(".section-item") if(section_item != null){ for (let index = 0; index < section_item.length; index++) { if (section_item[index].innerText.indexOf("学习中") > 0) { // if(realoadId ==0){ // realoadId = setInterval(reload , realoadTime*1000); // } // else{ // realoadTime=realoadTime-10; // } // msg("学习中-刷新时间:" + realoadTime); msg("学习中"); return; } } //学习下一项 for (let index = 0; index < section_item.length; index++) { if (section_item[index].innerText.indexOf("已完成") == -1) { msg("学习下一项"); section_item[index].click(); return; } } msg("学习完成!"); clearInterval(intervalId); } } function reload(){ document.location.reload(); } function msg( msgInfo){ const now = new Date(); const year = now.getFullYear(); const month = ('0' + (now.getMonth() + 1)).slice(-2); const day = ('0' + now.getDate()).slice(-2); const hours = ('0' + now.getHours()).slice(-2); const minutes = ('0' + now.getMinutes()).slice(-2); const seconds = ('0' + now.getSeconds()).slice(-2); const formattedTime = hours +":"+ minutes +":"+ seconds; console.log(document.title +"-"+formattedTime+ ":" + msgInfo) } var realoadId =0; var realoadTime =120; var intervalId = setInterval(study , 10000); msg("启动"); })();