You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.8 KiB

4 years ago
function input(info){
//输入
var s = prompt(info, "");
if(s == "" || s == null) return false;
return s;
}
function setNo(){
//设置课程信息
classNo = input("请输入课程序号(表格第一列)")
courseNo= input("请输入课程代码(表格第二列)")
document.getElementsByName("electableLesson.no")[0].value = classNo;
document.getElementsByName("electableLesson.course.code")[0].value = courseNo;
document.getElementsByName("electableLesson.course.name")[0].value = "";
document.getElementsByName("electableLesson.teachClass")[0].value = "";
document.getElementsByName("electableLesson.course.credits")[0].value = "";
document.getElementsByName("electableLesson.teachers")[0].value = "";
document.getElementsByName("electableLesson.campus.name")[0].value = "";
if(classNo && courseNo){ //输入正确
$("#electableLessonList_filter_submit").click();
setTimeout(function(){
if($("#electableLessonList_data").find("a[operator=ELECTION]").length != 1){
alert("无法使用本脚本,请亲手动选课吧。。。\n原因根据课程序号和课程代码选出了多个课程。。")
return false;
}
else{
alert("刷课即将开始,每隔" + refresh_time + "秒我会帮你看看还有没有名额\n为了避免选错请注意【可选课程页】的课程是否正确。请勿完全依赖本工具\n刷课状态会在控制台的console上显示。请低调使用\n如果控制台大量报错请检查登陆状态\nTip同时刷多门课可以开多个页面刷")
4 years ago
gogogo();
}
}, 500)
}else{
alert("输入有误!");
return false
}
}
function gogogo(){
//选课gogogo
$("#electableLessonList_filter_submit").click(); //模拟点击查询
setTimeout(function(){
try{
remain = parseInt($("#electableLessonList_data").find("td[class=stdCount]")[0].innerHTML);
if(remain <= 0){
//没有剩余名额
console.log("课程人数已满(" + remain + "" + 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)
4 years ago
}
}, 200) //这里的200毫秒是request时间因为没有回调所以写死了200
4 years ago
}
//屏蔽教务系统的错误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
4 years ago
setNo();