Created
September 5, 2023 11:13
-
-
Save KNN-07/a30f5dd2eef31e955901a2788ff8c2d5 to your computer and use it in GitHub Desktop.
CF Random Current Page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Codeforces Get Random | |
// @namespace https://github.com/KNN-07 | |
// @version 1.0 | |
// @description try to take over the world! | |
// @author KNN-07 / normankr07 | |
// @match https://*.codeforces.com/problemset* | |
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
let list = document.querySelector(".problems").querySelectorAll("tr:not(.accepted-problem)"); | |
let size = list.length; | |
let ranbtn = document.createElement("button"); | |
ranbtn.innerHTML = "Get Random"; | |
ranbtn.onclick = function () { | |
// let params = `scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no, | |
// width=0,height=0,left=-1000,top=-1000`; | |
// window.open(url, '_blank', params).focus(); | |
let id = Math.floor(Math.random() * (size + 1)); | |
let base = list[id].querySelector("a").getAttribute("href"); | |
let url = 'https://codeforces.com' + base; | |
window.open(url, '_blank').focus(); | |
}; | |
document.querySelector("._FilterByTagsFrame_main").children[2].appendChild(ranbtn); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment