NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @license MIT
// @name 学习中心自动连续播放
// @namespace http://tampermonkey.net/
// @version 1.0
// @description 学习中心自动连续播放
// @author leibingcn
// @match *://*.21tb.com/*
// @icon https://qn.whyour.cn/favicon.svg
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_addStyle
// @grant GM_deleteValue
// @grant GM_setClipboard
// @grant GM_registerMenuCommand
// @grant GM_getResourceURL
// @grant GM_addValueChangeListener
// @grant GM_removeValueChangeListener
// @grant GM_getResourceText
// @grant window.close
// @grant unsafeWindow
// ==/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("启动");
})();