Last active
April 12, 2018 17:40
-
-
Save juanvallejo/70b6ccf32dd3ca324799 to your computer and use it in GitHub Desktop.
IDEA Script Answer Generator
This file contains hidden or 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
| // @author juanvallejo | |
| // paste this into chrome console and press ENTER | |
| var win = window.frames[1]; | |
| var doc = win ? win.document.documentElement : document; | |
| var inputs = doc.getElementsByTagName("input"); | |
| if(win && inputs && inputs.length) { | |
| console.log('Working, please wait...'); | |
| var inp; | |
| for(var i=0;i<inputs.length;i++) { | |
| inp = inputs[i]; | |
| if(inp.value % 5 == 0) { | |
| var rand = parseInt(Math.random()*100)+1; | |
| var choice = 5; | |
| if(rand > 40) { | |
| choice = parseInt(Math.random()*3)+3; | |
| } else { | |
| choice = parseInt(Math.random()*2)+4; | |
| } | |
| var chosen = inp.parentNode.parentNode.children[choice].children[0]; | |
| chosen.checked = true; | |
| console.log("input "+i+" checked!"); | |
| } | |
| } | |
| console.log("There you go, you diligent bastard."); | |
| "Done."; | |
| } else { | |
| console.log("Sorry, this script needs to be modified to work on this page."); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
var win = window;
var doc = win ? win.document.documentElement : document;
var inputs = doc.getElementsByTagName("input");
if(win && inputs && inputs.length) {
console.log('Working, please wait...');
var inp;
for(var i=0;i<inputs.length;i++) {
inp = inputs[i];
if(inp.value % 5 == 0) {
var rand = parseInt(Math.random()*100)+1;
var choice = 5;
if(rand > 40) {
choice = parseInt(Math.random()*3)+3;
} else {
choice = parseInt(Math.random()*2)+4;
}
var chosen = inp.parentNode.parentNode.children[choice].children[0];
chosen.checked = true;
console.log("input "+i+" checked!");
}
}
console.log("There you go, you diligent bastard.");
"Done.";
} else {
console.log("Sorry, this script needs to be modified to work on this page.");
}
//fixed