Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Clear easy problems of Codeforces Problemset
// ==UserScript==
// @name Clean up Codeforces problemset
// @namespace http://tampermonkey.net/
// @version 0.3
// @description Filter problems of Codeforces Problemset by total of solved
// @author JHSN
// @match *://codeforces.com/problemset
// @match *://codeforces.com/problemset/
// @match *://codeforces.com/problemset/page/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var btn = document.createElement("BUTTON");
btn.textContent = "Clear";
btn.style.fontFamily = "verdana, arial, sans-serif";
btn.style.cursor = "pointer";
var clearf = function(s, l=0, r=1500){
var cnt=0;
var pat = /\d+/;
var trlist = document.getElementsByTagName("tr");
for (var i = 0; i < trlist.length; ++i) {
if (trlist[i].style.display == 'none' || !trlist[i].childNodes || trlist[i].childNodes.length < 8) continue;
var t = trlist[i].childNodes[9].textContent;
if (t.indexOf("Solved") != -1) continue;
var res = pat.exec(t);
if (!res) continue;
if (parseInt(res[0]) > r || parseInt(res[0]) < l) {
++cnt;
console.log(cnt, t);
trlist[i].style.display = "none";
}
}
console.log("Total of cleaned problem:", cnt);
};
btn.onclick = clearf;
var btnplace = document.getElementsByTagName("tbody")[1].children[0].children[2];
btnplace.textContent = "";
btnplace.appendChild(btn);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.