',
cancel: function(){
//右上角关闭回调
$("#layui-layer2").hide();
return false
}
});
$("#layui-layer2").hide();
//程序入口
function Inside(){
setSelectClassTimer()
setAutoVedioTimer()
}
//定义定时器
var outTimer;
var intTimer;
var loadTime;
//取出延迟启动值
try{
loadTime = GM_getValue('loadTime',3000)
}
catch(err){
GM_setValue('loadTime',3000)
loadTime = 3000
}
//设置自动选课定时器
function setSelectClassTimer(){
//自动选课
outTimer=setTimeout(function(){
AutoSelectCalss();
},loadTime);
}
//自动选课方法
function AutoSelectCalss(){
var $Lst=$(".el-progress__text")
for(var i=0;i<$Lst.length;i++){
if($Lst.eq(i).text()!="100%"){
if(!$Lst.eq(i).parent().parent().parent().parent().prev().find("h3").prev().is('.hj_bg_color'))
$Lst.eq(i).parent().parent().parent().parent().prev().find("h3").click()
$Lst.eq(i).parent().parent().click()
$Lst.eq(i).click()
return;
}
layer.msg('自动选课已运行完毕,若未自动选课,则请手动选课');
}
}
//等待时间设置
var stayTime;
//取出等待时间
try{
stayTime = GM_getValue('stayTime',33)
}
catch(err){
GM_setValue('stayTime',33)
stayTime = 33
}
//缓冲次数
var loadingTime=0;
//设置自动播放定时器
function setAutoVedioTimer(){
//定时判断视频是否暂停
intTimer=setInterval(function(){
try{
var vdo =$('video').get(0)
var State = vdo.paused
if(State){
ck()
}
//判断是否在缓冲
if($("#dplayer").is(".dplayer-loading")){
loadingTime+=1;
$("#nowIsLoading").text("缓冲中")
}else if($("#dplayer").is(".dplayer-playing")){
loadingTime=0;
$("#nowIsLoading").text("播放中")
}
//连续缓冲时间超过等待时间则重新载入页面
if(loadingTime>stayTime){
window.location.reload();
}
checkPage()
}
catch(err){
checkPage()
}
},300)
}
//重放日志
function ck(){
$(".dplayer-video-wrap").click()
$("#uul li:eq(0)").before('
'+getNow()+'重新播放
')
}
//时间获取
function getNow() {
var myDate = new Date();
var month=myDate.getMonth()+1;
var date=myDate.getDate();
var h=myDate.getHours();
var m=myDate.getMinutes();
var s=myDate.getSeconds();
var now = month+'/'+date+' '+h+':'+m+':'+s;
return now
}
//检查页面是否为课程视频页面
function checkPage(){
if(window.location.pathname!='/video'){
clearTimer()
$("#nowIsLoading").text("检测到当前页面不是播放页面,已停止运行脚本")
}
}
//定时器清除
function clearTimer(){
clearInterval(outTimer);
clearInterval(intTimer);
}
//显示延迟加载
$("#btnLoadTime").click(function(){
$("#layui-layer2").show()
$("#NowLoadTime").text(GM_getValue('loadTime',3000))
})
//自定义延迟启动
$("#btnUpdateLoadTime").click(function(){
var Time = $("#txtNum").val();
if (!(/(^[1-9]\d*$)/.test(Time)))
layer.msg("有误")
else{
layer.msg("启动延迟设置为 "+Time+" ms")
GM_setValue("loadTime",Time)
$("#layui-layer2").hide();
}
})
$("#btnReloadScript").click(function(){
clearTimer()
Inside();
$("#uul li:eq(0)").before('