学习网址:nxzj.chinahrt.com
脚本功能:屏蔽窗口失去焦点暂停学习
// ==UserScript==
// @name chinahrt屏蔽blur事件
// @namespace http://tampermonkey.net/
// @version 0.2
// @description 宁夏继续教育挂科,屏蔽自动暂停,实现自动播放(chrome除外)
// @author You
// @match https://videoadmin.chinahrt.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=chinahrt.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Your code here...
// 延时3秒后进入未学课程
window.sleep = function(ms){
return new Promise(resolve => setTimeout(resolve, ms || 1000))
};
// 延时3秒后进入未学课程
(async () => {
console.info("30秒后载入脚本...");
await sleep(30*1000);
console.info("尝试载入...");
window.onblur=null;
//$(".playchhpyuqipkah").click(); $(".timetextchmxscgeutrh").text().split("/")
//player.videoPlay();
console.info("载入成功!");
})();
var timer1=self.setInterval("myScript()",15000);
var sptime;
window.myScript=function()
{
//!!在函数前使用符号getElementsByClassName()将结果类型转换为布尔值,true如果有任何值则返回,false如果返回则返回null。
var playerplaybtn;
if(document.getElementsByClassName("timetextchmxscgeutrh").length>0)
{
sptime = $(".timetextchmxscgeutrh").text().split("/");
playerplaybtn=$(".playchhpyuqipkah");
}
else
{
sptime = $("div[class^='timetextch']").text().split("/");
playerplaybtn= $("div[class^='playch']");
}
console.info(sptime);
if( trim(sptime[0]) == "00:00")//初次加载
{
console.info("开始播放");
//player.videoPlay();
$(playerplaybtn).click();
}
else if(trim(sptime[0]) == sptime[1])//视频播放完成
{
//player.videoPlay();
$(playerplaybtn).click();
}
else
{
console.info("running...");
}
};
})();
下载地址:[tampermonkey_scripts (2).zip](http://www.herokay.cn/usr/uploads/2023/04/1730846944.zip)
chrome浏览器无法自动播放解决方案: