Skip to content

Instantly share code, notes, and snippets.

@uk-ar
Created January 25, 2021 19:36
Show Gist options
  • Save uk-ar/65f310a2af77cc6da4665569fb071143 to your computer and use it in GitHub Desktop.
Save uk-ar/65f310a2af77cc6da4665569fb071143 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://atcoder-tags.herokuapp.com/tag_search/*
// @grant GM_xmlhttpRequest
// ==/UserScript==
(function() {
'use strict';
GM_xmlhttpRequest({
method: "GET",
url: "https://kenkoooo.com/atcoder/atcoder-api/results?user=ukar",
onload: function(xhr)
{
let responseJson = JSON.parse(xhr.response)
console.log(xhr);
let m={};
responseJson.forEach(e => {
if(e.result=="AC"){
m[e.problem_id]="AC"
}else if(m[e.problem_id]!="AC"){
m[e.problem_id]="FAIL"
}
});
let colors = {"AC":"#c3e6cb","FAIL":"#ffeeba"}
for (const [problem_id, result] of Object.entries(m)) {
var node = document.evaluate("//strong[contains(text(), '"+problem_id+"')]", document, null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
if(node.snapshotItem(0)){
console.log(node.snapshotItem(0));
node.snapshotItem(0).parentNode.parentNode.parentNode.style.backgroundColor=colors[result];
}
}
console.log(m);
}
});
// Your code here...
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment