Created
October 5, 2020 12:31
-
-
Save trhgquan/864d0a22407ba755c2bcf06bc3acc761 to your computer and use it in GitHub Desktop.
using the result to cheat.
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
/** | |
* sample auto solve questions | |
* code by @trhgquan - https://github.com/trhgquan | |
*/ | |
function readCookie(name) { | |
var nameEQ = name + "="; | |
var ca = document.cookie.split(';'); | |
for (var i = 0; i < ca.length; i++) { | |
var c = ca[i]; | |
while (c.charAt(0) === ' ') c = c.substring(1, c.length); | |
if (c.indexOf(nameEQ) === 0) { | |
return c.substring(nameEQ.length, c.length) | |
} | |
} | |
return null; | |
} | |
// Read answer to a variable | |
var ans = readCookie("correctAnswers"); | |
// Index of a question. | |
var i = 0; | |
var interval = setInterval(function() { | |
// Get the element's text and print it to console. | |
let element = document.getElementById("answer" + ans[i++]); | |
console.log("Question " + i + ": " + element.innerText); | |
// Use the built-in function to answer. | |
answerQuestion(i, parseInt(ans[i - 1])); | |
// Condition to stop answering. | |
if (i === ans.length) { | |
clearInterval(interval); | |
console.log("Done"); | |
} | |
}, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment