Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
# eamisAutoClicker

NKU EAMIS选课脚本
> NKU EAMIS AutoClicker 南开大学教务系统选课抢课脚本

## 如何使用
- 打开浏览器console粘贴进去运行。会运行到所有要抢的课都成功后才会结束
- *建议使用`Chrome`或`Firefox`或`Edge`浏览器!!!* 使用其他浏览器不保证能正常运行
- inputId是储存要抢的课号的数组,手动修改添加即可
- 每次尝试抢哪个课的哪个分组由随机数确定,如果此课无分组输出时会显示undefined,是正常的
- sleepTime由随机数确定
- 若选课系统不同请将profileId改为对应选课系统的ID

1. 打开 [`clicker.js`](./blob/master/clicker.js) ,将代码复制或git clone到本地。
2. 仔细阅读开头的注释,修改候选课程列表。
3. 复制修改后的代码。
4. 打开浏览器,进入eamis教务系统的选课页面,按下F12(有些电脑需要Fn+F12)打开浏览器的开发人员工具。
![F12在这里](img/keyboard.png)
5. 在开发人员工具顶端找到控制台标签,点击切换过去。
![控制台在这里](img/console.png)
6. 在控制台粘贴代码,然后回车。
7. 挂着,别关浏览器,脚本会运行到所有要抢的课都成功后才会结束。

## 注意
- 抢已选上的课或者已修过的课会直接浏览器报错,脚本内的没有报错逻辑
- 建议使用 `Chrome` 或 `Firefox` 或 `Edge` 浏览器!!! 使用其他浏览器不保证能正常运行
- 每次尝试抢哪个课的哪个分组由随机数确定,如果此课无分组,输出时会显示undefined,是正常的
- sleepTime由随机数确定,如果你想让刷新频率更快,修改cliker.js:16即可,但是请自觉调低频率,不要给学校服务器带来过多压力。
- 所有课程均抢到后才有窗口提示。抢到其中某一门课只会在console输出一条成功的log
- 抢到课后不会在课表中立即显示出来,需要刷新选课页面

## LOG
- 2022.02.10 自动获取当前选课页面的profileId,面向无代码经验的使用者优化了注释和使用说明
- 2021.05.13 重新格式化代码,修改了一些不太合理的写法
- 2021.01.14 2021春季学期正选
- 2020.08-30 2020年秋季学期正选
Expand Down
19 changes: 13 additions & 6 deletions clicker.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
// 把下面的数组元素修改为你想选的课程序号(不是课程代码,是选课页面最左侧那一列的数值)
// 注意格式,每个课程序号用英文单引号括起来,多个课程之间用英文逗号分割。比如这里是要选课0416文科概率统计和0428高等数学(B类)II
const courseId = ['0416', '0428'];

function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}

// 把下面的数组元素修改为你想选的课程编号
const courseId = ['1108', '1434'];
// 在这里修改选课系统ID
const profileId = '834';

async function mainFunction(courseId) {
const eamisUrl = window.location.href
const profileId = eamisUrl.substring(eamisUrl.search(/[0-9]+/), eamisUrl.length)

let idInd = 0;
while (courseId.length > 0) {
// 在这里修改随机等待时长
// 如有需要,在这里修改随机等待时长的计算规则(不建议修改)
const sleepTime = Math.ceil(Math.random() * 200) + 300;
const id = courseId[idInd++];
idInd %= courseId.length;
$("input[name='electableLesson.no']").val(id);
$('#electableLessonList_filter_submit').click();
const targetId = $("tr[class='electGridTr electGridTr-even']").attr('id');
if (targetId == null) {
courseId.splice($.inArray(id, courseId), 1);
console.log(`Failed... Id: ${id}, course unavailable!`);
continue;
}
const shortId = targetId.substr(6, 6);
const expLesson = `#expLessonGroups_${targetId.substr(6, 6)}`;
let groupId;
Expand Down
Binary file added img/console.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/keyboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.