-
Notifications
You must be signed in to change notification settings - Fork 1
/
vjudge.mjs
40 lines (38 loc) · 930 Bytes
/
vjudge.mjs
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
import { day, getPage } from "./tool.mjs";
import config from "./config.json";
const cookie = config.cookie.vjudge;
async function _vjudge(username) {
let get = async (start) => {
return JSON.parse(await getPage({
url: `https://vjudge.net/status/data/?draw=1&start=${start}&length=20&un=${username}&OJId=All&probNum=&res=1&language=&onlyFollowee=false`,
headers: {
cookie: `JSESSIONID=${cookie.JSESSIONID}`,
},
method: 'GET',
}));
};
let check = (content) => {
return content.data;
};
let list = [];
for (let start = 0, content; check(content = await get(start)); start += 20) {
content = content.data;
let paused = false;
for (let submission of content) {
if (submission.time < day) {
paused = true;
break;
}
let oj = submission.oj;
let id = submission.probNum;
list.push(`[VJudge] ${oj} ${id}`);
}
if (paused) {
break;
}
}
return list;
}
export {
_vjudge,
}