-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathjudge.js
More file actions
119 lines (101 loc) · 2.58 KB
/
Copy pathjudge.js
File metadata and controls
119 lines (101 loc) · 2.58 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
function xpath(query, index = 1) {
let matches = document.evaluate(
query,
document,
null,
XPathResult.ANY_TYPE,
null,
);
let result;
for (let _i = 0; _i < index; _i++) {
result = matches.iterateNext();
}
return result;
}
function allgood() {
let index = 1;
let good = xpath(
'//div[@id="txwj-index-card"]//label[text()[contains(.,"很好")]]//input[@type="radio"]',
index,
);
console.info(`全部打非常好`);
while (good != null) {
good.checked = true;
index++;
good = xpath(
'//div[@id="txwj-index-card"]//label[text()[contains(.,"很好")]]//input[@type="radio"]',
index,
);
}
}
async function submit() {
let submit = xpath(
'//footer[@id="txwjFooter"]//a[text()[contains(.,"提交")]]',
);
console.info(`提交`);
submit.click();
await sleep(200);
let confirm = xpath('//a[text()[contains(.,"确认")]]');
if (confirm) {
console.info(`确认提交`);
confirm.click();
}
await sleep(4000);
let no_recommend = xpath(
'//div[@id="buttons"]//button[text()[contains(.,"暂不推荐")]]',
);
if (no_recommend) {
console.info(`不推荐我最喜爱的老师`);
no_recommend.click();
}
await sleep(200);
let no_tas = xpath(
'//div[@class="bh-dialog-btnContainerBox"]//a[text()[contains(.,"暂时不评")]]',
);
if (no_tas) {
console.info(`暂不评价助教`);
no_tas.click();
}
}
// 为了跳过已经出成绩、无法评教的课。从1开始。
let next_judge_button_index = 1;
async function next() {
let judge_next = xpath(
'//section[@class="ckdwpj"]//div[@style="display: block;"]//div[@class="card-btn blue"]',
next_judge_button_index,
);
if (judge_next == null) {
console.info(`没有下一个要评价了`);
return false;
}
console.info(`评价下一个`, judge_next);
judge_next.click();
// 如果有课已经出成绩了,就会无法评教。
// 检测是否为该情况
await sleep(700);
let cannot_judge = xpath('//div[@class="bh-tip-top-bar"]');
if (cannot_judge != null) {
console.warn(`无法评教`);
next_judge_button_index += 1;
let close = xpath('//a[@class="bh-tip-closeIcon"]');
console.info(`关闭无法评教提示`);
close.click();
await sleep(700);
return await next();
}
return true;
}
async function main() {
next_judge_button_index = 1;
while (await next()) {
await sleep(1000);
allgood();
await submit();
await sleep(500);
}
console.log("Done");
}
await main();