forked from Durden-T/BUPTtakeCourse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bupt-take-specific-course.js
63 lines (54 loc) · 1.39 KB
/
bupt-take-specific-course.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// https://github.com/Durden-T/BUPTtakeCourse
var courses = [
//'下一代Internet技术与协议',
//'体育专项(下)[男]',
//'3D打印创新实践(双创)',
];
//抢课时间间隔,单位为ms,抢课50ms, 捡漏300ms
var interval = 300;
//禁止改动
var targets = [];
var running;
function getCourses() {
let params = {
sEcho: 1,
iColumns: 11,
iDisplayStart: 0,
iDisplayLength: 99999,
};
let paths = [
'/jsxsd/xsxkkc/xsxkBxxk', //必修
'/jsxsd/xsxkkc/xsxkXxxk', //选修
'/jsxsd/xsxkkc/xsxkGgxxkxk', //公选
];
for (let path of paths)
$.post(path, params, processData);
}
function processData(resp) {
let data = $.parseJSON(resp).aaData;
for (let course of data)
if (courses.indexOf(course.kcmc) != -1)
targets.push([course.kch, course.jx0404id]);
}
function takeCourses(targets) {
if (!targets.length)
getCourses();
for (let target of targets)
$.ajax({
url: "/jsxsd/xsxkkc/xxxkOper",
data: {
kcid: target[0],
jx0404id: target[1]
}
});
console.log('running......');
}
function start() {
running = window.setInterval(takeCourses, interval, targets);
console.log('start');
}
function stop() {
window.clearInterval(running);
console.log('stop');
}
start();