Colorize the CafeCoder standings page.
当前为
// ==UserScript==
// @name CafeCoderStandingsColorizer
// @namespace https://makutamoto.com/
// @version 0.1
// @description Colorize the CafeCoder standings page.
// @author Makutamoto
// @match https://cafecoder.top/contests/*/standings
// @grant none
// ==/UserScript==
(function() {
'use strict';
const trying = 0;
const interval = setInterval((async () => {
const colors = ['gray', 'brown', 'green', 'cyan', 'blue', 'yellow', 'orange', 'red'];
const users = document.querySelectorAll("tbody tr th");
if(users.length == 0) {
trying++;
if(trying > 10) clearInterval(interval);
return;
}
clearInterval(interval);
for(let user of users) {
fetch(`https://atcoder-badges.now.sh/api/rating/${user.innerText}`).then((data) => {
data.json().then((data) => {
const rating = data.rating === null ? null : (data.rating.atcoder === null ? null : data.rating.atcoder);
if(rating) user.style.color = colors[Math.floor(rating / 400)];
})
});
}
}), 250);
})();