Last active
November 9, 2018 10:33
-
-
Save EcutDavid/9496f08ca92c6406c2c5b7ef4be483b4 to your computer and use it in GitHub Desktop.
Download Codeforces test cases
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
var inputs = document.querySelectorAll(".input pre"); | |
for (var i = 0; i < inputs.length; i++) { | |
var s = inputs[i].innerHTML; | |
s = s.replace(/<br>/g, "\n"); | |
console.log(s) | |
// decode html entities | |
var div = document.createElement("div"); | |
div.innerHTML = s; | |
s = div.textContent; | |
// for Windows | |
s = s.replace(/\n/g, "\r\n"); | |
var a = document.createElement("a"); | |
a.setAttribute("href", "data:text/plain," + encodeURIComponent(s)); | |
a.setAttribute("download", "tests" + i + ".txt"); | |
document.body.appendChild(a); | |
a.click(); | |
} |
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
javascript:for(var inputs=document.querySelectorAll(".input pre"),i=0;i<inputs.length;i++){var s=inputs[i].innerHTML;s=s.replace(/<br>/g,"\n"),console.log(s);var div=document.createElement("div");div.innerHTML=s,s=(s=div.textContent).replace(/\n/g,"\r\n");var a=document.createElement("a");a.setAttribute("href","data:text/plain,"+encodeURIComponent(data)),a.setAttribute("download","tests"+i+".txt"),document.body.appendChild(a),a.click()} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment