NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name E-Olymp Colorizer // @namespace https://github.com/MineGeekYT // @version 0.3 // @description Was it really hard to implement, devs? // @author MineGeek // @exlcude * // @include *e-olymp.com/ru/contests/* // @exclude *e-olymp.com/ru/contests/*/problems/* // @grant none // ==/UserScript== var problems = document.getElementsByClassName("eo-list__item eo-problem-row"); console.log(document); var xhr = []; var helperFunc = function(i){ return function(){ if(xhr[i].readyState === 4){ ProcessResponseForItem(i); } }; }; for (var i = 0; i < problems.length; i++){ console.log("XMLHttpRequest " + i.toString() + " started\n"); var url = problems[i].firstChild.href; xhr.push(new XMLHttpRequest()); xhr[i].open('GET', url, true); xhr[i].responseType = "document"; xhr[i].onreadystatechange = helperFunc(i); xhr[i].send(null); } function ProcessResponseForItem(i){ if(xhr[i].status === 200){ var cn = xhr[i].response.getElementsByClassName("eo-paper")[0].firstChild.className; console.log("XMLHttpRequest " + i.toString() + " is being processed\n"); console.log("Classes are " + cn + "\n"); if (cn.indexOf("eo-problem-status_wrong") !== -1){ colorize(i, 1); } else if (cn.indexOf("eo-problem-status_accepted") !== -1){ colorize(i, 2); } else{ colorize(i, 0); } } } function colorize(i, type){ problems[i].firstChild.removeAttribute("class"); var color = "gray"; if (type === 1){ color = "#eb6c6c"; } else if (type === 2){ color = "#abeb6c"; } problems[i].firstChild.style.cssText = "-webkit-box-flex: 0; -webkit-flex: none; -ms-flex: none; flex: none; color: #fff; margin: 0 10px; width: 26px; height: 26px; line-height: 26px; -webkit-border-radius: 50%; border-radius: 50%; background: " + color + "; text-align: center;"; }