找个地方放代码
// ==UserScript==
// @name 2021年惠来县小学教师全员轮训
// @namespace Violentmonkey Scripts
// @match http*://study.teacheredu.cn/proj/studentwork/study.htm*
// @match http*://study.teacheredu.cn/proj/studentwork/courseListNew*
// @match http*://study.teacheredu.cn/proj/studentwork/course_list_new.htm*
// @grant none
// @version 1.0
// @author -
// @description 2021/8/6 下午9:30:45
// ==/UserScript==
init();
/**
* 执行入口
*/
function init() {
if (window.location.href.includes('studentwork/study.htm')) {
//视频页
console.log('准备执行视频页脚本');
setTimeout(function () {
study();
}, 1000);
} else if (window.location.href.includes('courseListNew')) {
//课程页
console.log('课程页');
setTimeout(function () {
handleCourse();
}, 1500);
// 80分钟后,新窗口就关了,该打开新窗口了
setTimeout(function () {
window.location.reload();
}, 4810000);
}
}
function study() {
console.log(randomTime);
// 设置randomTime 为-1 ,不弹窗。
randomTime = -1;
let timeI = 0;
let playingInterval;
playingInterval = setInterval(function () {
console.log('定时器存活 ');
// if(timeI == 10) {
// console.log('测试关窗口' + timeI);
// window.close();
// }
timeI = timeI+1;
// 20分钟执行一次存时间
if(timeI%1200 == 0) {
console.log('执行存储时间' + timeI);
console.log('执行存储时间' + timeI);
updateStudyTime(0);
}
// 操作弹窗
var _alert=window.alert;
window.alert=function(msg){
console.log(msg);
_alert.dismiss();
}
var _confirm=window.confirm;
window.confirm=function(msg){
console.log(msg);
return true;
}
// 一个小时20分钟后退出
if(timeI == 4810) {
// if(timeI == 5) {
// exit_study_btn
// console.log(document.querySelectorAll('.video_title_time fr'));
exitStudy();
// window.close();
return true;
}
}, 1000)
}
function handleCourse() {
// kcxx_side_title fl Course_list_info
console.log(document.querySelectorAll('.list'));
let list = document.querySelectorAll('.list');
if( !list.length ) {
window.location.reload();
return;
}
for (let i = 0 ;i<list.length ;i+=1) {
let strings = list[i].children[0].childNodes[3].childNodes[1].outerText;
// console.log(strings);
var str ;
str = strings.match(/已学习 (\S*) 分钟/)[1];
// console.log(str);
if(parseInt(str) <= 40) {
list[i].children[0].childNodes[1].childNodes[1].onclick();
window.close();
break;
}
}
}
// ==UserScript==
// @name 2021年惠来县小学幼儿园“三区”教师全员轮训
// @namespace Violentmonkey Scripts
// @match http*://study.teacheredu.cn/proj/studentwork/study.htm*
// @match http*://study.teacheredu.cn/proj/studentwork/courseListNew*
// @match http*://study.teacheredu.cn/proj/studentwork/course_list_new.htm*
// @grant none
// @version 1.0
// @author -
// @description 2021/8/6 下午9:30:45
// ==/UserScript==
init();
/**
* 执行入口
*/
function init() {
if (window.location.href.includes('studentwork/study.htm')) {
//视频页
console.log('准备执行视频页脚本');
setTimeout(function () {
study();
}, 1000);
} else if (window.location.href.includes('courseListNew')) {
//课程页
console.log('课程页');
setTimeout(function () {
handleCourse();
}, 1500);
// 80分钟后,新窗口就关了,该打开新窗口了
setTimeout(function () {
window.location.reload();
}, 4810000);
}
}
function study() {
console.log(randomTime);
// 设置randomTime 为-1 ,不弹窗。
randomTime = -1;
let timeI = 0;
let playingInterval;
playingInterval = setInterval(function () {
console.log('定时器存活 ');
// if(timeI == 10) {
// console.log('测试关窗口' + timeI);
// window.close();
// }
timeI = timeI+1;
// 20分钟执行一次存时间
if(timeI%1200 == 0) {
console.log('执行存储时间' + timeI);
console.log('执行存储时间' + timeI);
updateStudyTime(0);
}
// 操作弹窗
var _alert=window.alert;
window.alert=function(msg){
console.log(msg);
_alert.dismiss();
}
var _confirm=window.confirm;
window.confirm=function(msg){
console.log(msg);
return true;
}
// 一个小时20分钟后退出
if(timeI == 4800) {
window.close();
return true;
}
}, 1000)
}
function handleCourse() {
// kcxx_side_title fl Course_list_info
console.log(document.querySelectorAll('.list'));
let list = document.querySelectorAll('.list');
if( !list.length ) {
window.location.reload();
return;
}
for (let i = 0 ;i<list.length ;i+=1) {
let strings = list[i].children[0].childNodes[3].childNodes[1].outerText;
// console.log(strings);
var str ;
str = strings.match(/已学习 (\S*) 分钟/)[1];
// console.log(str);
if(parseInt(str) <= 30) {
list[i].children[0].childNodes[1].childNodes[1].onclick();
break;
}
}
}