Created
April 3, 2017 14:41
-
-
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.
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 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