登录,打开学习页面,将自动学习
// ==UserScript==
// @name longlong-在线研修个人用
// @namespace http://tampermonkey.net/
// @version 1.4
// @description 登录,打开学习页面,将自动学习
// @author longlong
// @match https://zy.jsyx.sdedu.net/*
// @icon https://zy.jsyx.sdedu.net/
// @grant none
// @icon https://zxp.rf.gd/img/favicon.ico
// @license MIT
// ==/UserScript==
(function () {
'use strict';
setTimeout(function () {
if (typeof window.interval !== 'undefined') {
window.interval = 9;
console.log('油猴脚本:已将视频更新间隔强制设置为 ' + window.interval + ' 秒。');
} else {
console.warn('油猴脚本:未能找到全局变量 interval,可能无法修改更新频率。');
}
}, 1000); // 延迟 1 秒执行,确保页面原始脚本已运行
function play() {
if (typeof ($('video')[0]) != "undefined") {
let v = $('video')[0];
v.muted = true;
v.play();
}
var promptText = $(".g-study-prompt p ")[0]?.innerText || "";
if (promptText.indexOf("作业") >= 0) {
if (playTimer) {
clearInterval(playTimer); // 停止定时器
console.warn('做作业,停止脚本,手动跳往下一章节');
}
return;
}
const nextLink = $("#studySelectAct a")[1]; //检测已完成任务1
const nextLinkClasses = nextLink ? nextLink.className : '';
if (promptText.indexOf("您已完成观看") >= 0) {
if (nextLink.className.includes("btn next disable")) { //最后一章
console.log('任务完成,停止脚本,手动跳往下一章节');
clearInterval(playTimer); // 停止定时器
return;
}else{//点击下一章
$("#studySelectAct a")[1]?.click();
console.log("学习完成提示出现,已自动跳转到下一章节。");
return
}
}
var timer1Element = $(".g-study-prompt p span")[0];//检测已完成任务2
var timer2Element = $(".g-study-prompt p span")[1];
if (timer1Element && timer2Element) {
var timer1 = timer1Element.innerText; // 已观看时间(分钟)
var timer2 = timer2Element.innerText; // 要求观看时间(分钟)
if (parseInt(timer1) <= parseInt(timer2)) {
if (nextLink.className.includes("btn next disable")) { //最后一章
console.log('任务完成,停止脚本,手动跳往下一章节');
clearInterval(playTimer); // 停止定时器
return;
}else{//点击下一章
$("#studySelectAct a")[1]?.click();
console.log("学习完成提示出现,已自动跳转到下一章节。");
return
}
}
}
}
const playTimer = setInterval(play, 2000);
})();