Skip to content
Merged
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: 18 additions & 5 deletions AtCoderColorNEWS.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// @author nullnull
// @match https://atcoder.jp
// @require https://cdn.rawgit.com/jaredreich/notie.js/a9e4afbeea979c0e6ee50aaf5cb4ee80e65d225d/notie.js
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
// ==/UserScript==

(async function () {
Expand Down Expand Up @@ -43,19 +44,31 @@
return `${E(username)}さんのレートが${color[nowRate]}色に変わりました!<br>`;
}).join("");

notie.alert(3, string, 20); //20秒後、またはクリックで消える
if (string.length > 0) {
notie.alert(3, string, 20); //20秒後、またはクリックで消える
}
})();

//Rateを色に変換する
function getColorIndex(rate){
function getColorIndex(rate) {
return Math.min(8, Math.floor(rate / 400));
}

function getLatestContestScreenName() {
//TODO:URLのabc123みたいな奴をとってくる
return "agc036";
//HTMLの構造が変わったらバグりそう。

//<a href="/contests/agcXXX">AtCoder Grand Contest XXX</a>
let contestScreenName = document.getElementById("collapse-contest").getElementsByClassName("table table-default table-striped table-hover table-condensed small")[2].getElementsByTagName('small')[1].innerHTML;

//contests/agcXXX
contestScreenName = contestScreenName.split('"')[1];

//agcXXX
contestScreenName = contestScreenName.split('/').pop();

return contestScreenName;
}

async function getContestResultData(contestScreenName) {
return await $.ajax(`https://atcoder.jp/contests/${contestScreenName}/results/json`);
}
}