Skip to content

Instantly share code, notes, and snippets.

@juanvallejo
Last active April 12, 2018 17:40
Show Gist options
  • Select an option

  • Save juanvallejo/70b6ccf32dd3ca324799 to your computer and use it in GitHub Desktop.

Select an option

Save juanvallejo/70b6ccf32dd3ca324799 to your computer and use it in GitHub Desktop.
IDEA Script Answer Generator
// @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.");
}
@CortlandLizer
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment