Last active
May 3, 2024 19:34
-
-
Save DarkMio/e6509d0325dd11ebde6306591d611540 to your computer and use it in GitHub Desktop.
Gooboo School Math Solver
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
const cancel = (() => { | |
const handle = setInterval(() => { | |
const element = document.querySelector(".v-text-field__slot > input"); | |
const questionElement = document.querySelector(".question-text > :nth-child(1)"); | |
if(!element || !questionElement) { | |
return; | |
} | |
const text = questionElement.innerText.replaceAll('_', ' '); | |
element.value = text; | |
element.dispatchEvent(new Event("input", { | |
bubbles: true, | |
cancelable: true | |
})) | |
}, 16); | |
return () => clearInterval(handle); | |
})() |
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
// I'm lazy, so why shouldn't math solve itself? | |
// for gooboo, the game | |
const cancel = (() => { | |
const handle = setInterval(() => { | |
const element = document.querySelector("#answer-input-math") | |
const question = document.querySelector(".question-text"); | |
if (!element || !question) { | |
return; | |
} | |
const questionText = question.innerHTML; | |
if(questionText.includes("√")) { | |
const { number } = /(?<number>\d+)/.exec(questionText)?.groups | |
element.value = Math.sqrt(parseInt(number)); | |
} else if(questionText.includes("^")) { | |
const { base, exponent } = /(?<base>\d+)\ \^\ (?<exponent>\d+)/.exec(questionText)?.groups; | |
element.value = Math.pow(parseInt(base), parseInt(exponent)); | |
} else { | |
element.value = eval(question.innerHTML); | |
} | |
element.dispatchEvent(new Event("input", { | |
bubbles: true, | |
cancelable: true | |
})); | |
element.dispatchEvent(new KeyboardEvent('keydown', { | |
'key': 'Enter', | |
keyCode: 13, | |
code: "enter", | |
which: 13 | |
})); | |
}, 16); | |
return () => clearInterval(handle); | |
})() | |
// I'd also like to point out that this code is shoddy, but I'm even too lazy for that. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment