'}
GM_setValue("donate_count",new Date().getTime()+ 1000*3600*24*365 )
setTimeout(function(){window.location.reload()},1500)
}
setInterval(function(){
if(/study\/errors/.test(window.location.href)){
new ElegantAlertBox("准备关闭页面>__<")
window.close()
}
},5000)
if(!GM_getValue("doing")){
//init
GM_setValue("doing",{"name":"","time":1,"status":""})
}
if(!GM_getValue("donate_count")){
//init
GM_setValue("donate_count",new Date().getTime())
}
var donate_flag = true;
if(GM_getValue("donate_count") && new Date().getTime()- GM_getValue("donate_count") > 1000*30*3600*24){
//donate
donate_flag = false ;
var script = document.createElement('script');
script.src = 'https://cdn.bootcdn.net/ajax/libs/layer/3.5.1/layer.min.js'; // Layer.js CDN链接
document.head.appendChild(script);
script.onload = function() {
layer.open({
type: 1,
title: '捐助页面',
closeBtn:0,
anim: 2,
area: [Number(document.body.clientWidth/2)+"px",Number(document.body.clientHeight*0.9)+"px"],
shadeClose: false,
offset: 'auto', // 居中显示
skin: 'layui-layer-demo', // 无背景色
content: `
如果脚本对你有帮助,可以捐助我一瓶快乐水
有了快乐水,我就可以写出更多对你有帮助的脚本
`,
});
}
}
function click_course(){
//查找并点击需要学习的课程
for(let i of document.querySelectorAll(".item[data-resource-id]")){
let status = i.querySelector(".operation").innerText
let name = i.querySelector(".name-des").innerText
if(/(继续学习)|(开始学习)/.test(status)){
GM_setValue("doing",{"name":name,"time":new Date().getTime(),"status":status})
i.click()
return true
}
}
return false
}
if(donate_flag){
if(/study\/subject\/detail/.test(window.location.href)){
// 课程主页,在当前页面实现控制做哪些课程
new ElegantAlertBox("初始化中,请等待>__<")
setInterval(function(){
let doing_item = GM_getValue("doing")
let next_flag = false
if(new Date().getTime()-doing_item.time>1000*20){
//超过20s没有更新状态视为过期
next_flag = true
new ElegantAlertBox("准备开始新的课程>__<")
}else{
next_flag = false
new ElegantAlertBox("貌似有课程正在观看,检查中,请等待>__<")
}
if (next_flag){
if(click_course() ){
//有需要做的课程,已经点击
new ElegantAlertBox("已打开新的学习页面学习>__<")
}else{
new ElegantAlertBox("找不到需要学习的内容>__<")
}
}
},5000)
}else if(/study\/course\/detail/.test(window.location.href)){
//视频播放页,做完后给主页一个标志,结束标签页
new ElegantAlertBox("检查中,请等待>__<")
setInterval(function(){
let name = document.querySelector("div.title-row > div")
if(name){
name = name.innerText
}else{return}
GM_setValue("doing",{"name":name,"time":new Date().getTime(),"status":"学习中"})
let state = document.querySelector("dl.focus > div.chapter-right > div.section-item.section-item11 > div:nth-child(3) > span")
state = state?state.innerText:null
if(state == "已完成"){
new ElegantAlertBox("准备播放下一个视频>__<")
let courses = document.querySelectorAll("dl")
for(let i of courses){
if(i.querySelector("div.chapter-right > div.section-item.section-item11 > div:nth-child(3) > span").innerText != "已完成"){
i.click()
return
}
}
new ElegantAlertBox("全部学习完>__<")
GM_setValue("doing",{"name":name,"time":new Date().getTime()-1000*30,"status":"已完成"})
GM_setValue(name,{"name":name,"time":new Date().getTime()-1000*30,"status":"已完成"})
window.close()
}else{
new ElegantAlertBox("还没有学习完 >__<")
if(document.querySelector(".register-mask-layer") && 'display: none;' != document.querySelector(".register-mask-layer").getAttribute("style")){
document.querySelector("#D210registerMask").click()
}
document.querySelector("video").muted="muted"
document.querySelector("button.vjs-big-play-button").click() //开始播放的按钮
}
},5000)
}
}
})();