BUPT抢课脚本

浏览器f12打开控制台运行

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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// ----- 需要配置的参数 -----
/* 需要抢的课程名称, 必修、选修、公选通用, 需要和教务系统上的课程名称完全一致 */
let COURSES = [
"蛙泳[男]",
];
/* 需要抢的课程分组名称, 必修、选修、公选通用, 可以用于体育专项的抢课, 需要完全一致 */
let COURSE_GROUPS = [
];
/* 抢课间隔, 单位毫秒. 推荐数值: 抢课 100ms, 捡漏 500ms */
let INTERVAL_MS = 1000;
/* 是否开启公选课抢课, 默认关闭, 以防止抢到课程名一样的公选课 */
let ENABLE_GGXXK = false;
// ------------------------

// 以下不需要修改

let mainInterval;
let targetCourses = [];

const start = () => {
mainInterval = setInterval(handler, INTERVAL_MS);
console.log("--- start grabbing courses ---");
};

const stop = () => {
clearInterval(mainInterval);
console.log("--- stop grabbing courses ---");
};

const handler = () => {
if (targetCourses.length === 0) {
getCourses();
}

console.log(
`--- found ${targetCourses.length} courses ---`
);

let paths = [
"/jsxsd/xsxkkc/xxxkOper", // 选修
"/jsxsd/xsxkkc/bxxkOper", // 必修
];
if (ENABLE_GGXXK) {
paths.push("/jsxsd/xsxkkc/ggxxkxkOper"); // 公选
}
for (let course of targetCourses) {
for (let path of paths) {
$.get(path, course, console.log);
}
}
};

const getCourses = () => {
let params = {
sEcho: 1,
iColumns: 11,
iDisplayStart: 0,
iDisplayLength: 999,
};
let paths = [
"/jsxsd/xsxkkc/xsxkBxxk", // 必修
"/jsxsd/xsxkkc/xsxkXxxk", // 选修
];
if (ENABLE_GGXXK) {
paths.push("/jsxsd/xsxkkc/xsxkGgxxkxk"); // 公选
}
for (let path of paths) {
$.post(path, params, (data) => {
let aaData = $.parseJSON(data).aaData;
for (let course of aaData) {
if (COURSES.includes(course.kcmc)) {
targetCourses.push(course);
} else if (COURSE_GROUPS.includes(course.fzmc)) {
targetCourses.push(course);
}
}
});
}
};

start();

BUPT抢课脚本
http://example.com/2024/11/27/Notes/花里胡哨/BUPT抢课脚本/
许可协议