添加错误处理。修复教务系统alert后无法继续选课的bug

This commit is contained in:
斐斐 2021-01-13 10:54:21 +08:00
parent 75582019ed
commit eb0218d04d

View File

@ -38,25 +38,37 @@ function gogogo(){
//选课gogogo
$("#electableLessonList_filter_submit").click(); //模拟点击查询
setTimeout(function(){
if($("#electableLessonList_data").find("td[class=stdCount]")[0].innerHTML == "0"){
//没有剩余名额
console.log("课程人数已满," + refresh_time + "秒后再试");
setTimeout("gogogo()", refresh_time * 1000 - 1000)
}else{
console.log("有了");
//屏蔽confirm
_tmp_confirm = window.confirm;
window.confirm = function () {
return true;
};
//模拟点击选课按钮
$("#electableLessonList_data").find("a[operator=ELECTION]").click()
//恢复confirm
window.confirm = _tmp_confirm
try{
if($("#electableLessonList_data").find("td[class=stdCount]")[0].innerHTML == "0"){
//没有剩余名额
console.log("课程人数已满," + refresh_time + "秒后再试");
setTimeout("gogogo()", refresh_time * 1000 - 200)
}else{
console.log("有了");
//模拟点击选课按钮
$("#electableLessonList_data").find("a[operator=ELECTION]").click()
//恢复confirm和alert
window.confirm = _tmp_confirm
window.alert = _tmp_alert
}
}catch(err){
console.log(err);
console.log("雾草,出错了,不过没关系,刷课还在继续");
setTimeout("gogogo()", refresh_time * 1000 - 200)
}
}, 1000)
}, 200) //这里的200毫秒是request时间因为没有回调所以写死了200
}
refresh_time = 3; //刷课间隔可以手动修改最低为2
//屏蔽教务系统的错误alert和确认comfirm
_tmp_alert = window.alert
window.alert = function () {
return true;
};
_tmp_confirm = window.confirm;
window.confirm = function () {
return true;
};
refresh_time = 1.1; //刷课间隔可以手动修改最低为1
setNo();