Created
May 21, 2024 08:05
-
-
Save archy-bold/da1130250e1e95d5671794239c30c109 to your computer and use it in GitHub Desktop.
JavaScript to fill in Scoredle
This file contains hidden or 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 answers = ['stare', 'moldy', 'bidon', 'dingo', '', '']; | |
for (var i = answers.length - 1; i >= 0; i--) { | |
if (answers[i] != '') { | |
changeInput('#answer', answers[i]); | |
break; | |
} | |
} | |
for (var i = 0; i < answers.length; i++) { | |
if (answers[i] != '') { | |
changeInput('#guess' + i, answers[i]); | |
} | |
else { | |
break; | |
} | |
} | |
function changeInput(query, val) { | |
var input = document.querySelector(query); | |
var nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value").set; | |
nativeInputValueSetter.call(input, val); | |
var ev2 = new Event('change', { bubbles: true}); | |
input.dispatchEvent(ev2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment