-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodeforces.js
More file actions
38 lines (36 loc) · 1.21 KB
/
codeforces.js
File metadata and controls
38 lines (36 loc) · 1.21 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
window.browser = (function () {
return window.msBrowser || window.browser || window.chrome;
})();
// this will contain all ongoing submissions
var statuses = [].slice
.call(document.getElementsByClassName("status-cell"))
.filter((it) => it.getAttribute("waiting") === "true");
// function which fetch the result
let fetch_codeforces_result = function () {
statuses.forEach((st, i, ob) => {
var wait =
st.getElementsByClassName("verdict-waiting").length > 0 ||
st.getElementsByTagName("span").length === 0;
if (wait && st.innerText === "Compilation error") {
wait = false;
}
if (wait == false) {
let verdict = st.innerText;
let time = [].slice.call(
st.parentElement.getElementsByClassName("time-consumed-cell")
)[0].innerText;
let mem = [].slice.call(
st.parentElement.getElementsByClassName("memory-consumed-cell")
)[0].innerText;
browser.runtime.sendMessage({
verdict: verdict,
time: time,
mem: mem,
id: st.getAttribute("submissionid"),
});
ob.splice(statuses.indexOf(st), 1);
}
});
setTimeout(fetch_codeforces_result, 100);
};
fetch_codeforces_result();