Skip to content

Instantly share code, notes, and snippets.

@4rshdeep
Created April 3, 2017 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 4rshdeep/b1a9d071c47520395d6c9ae9b054b4f0 to your computer and use it in GitHub Desktop.
Save 4rshdeep/b1a9d071c47520395d6c9ae9b054b4f0 to your computer and use it in GitHub Desktop.
Open https://moodle.iitd.ac.in/login/index.php Copy paste the code in the console.
var field = document.getElementById('valuepkg3');
var condition = field.previousSibling.textContent;
var numbers = condition.match(/\d+/g).map(Number);
var myInt = 0;
if(condition.includes('first')){
myInt = numbers[0];
}
else if(condition.includes('add')){
myInt = numbers[0]+numbers[1];
}
else if(condition.includes('second')){
myInt = numbers[1];
}
else if(condition.includes('subtract')){
myInt = numbers[0] - numbers[1];
}
field.value = myInt;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment