Created
February 3, 2022 19:01
-
-
Save twanmulder/004cb67633e719a114d44b6b7d4eef3a to your computer and use it in GitHub Desktop.
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
(function winAtWordle() { | |
// Wait for current game state to be loaded | |
if (!window.localStorage.gameState) { | |
return setTimeout(winAtWordle, 100); | |
} | |
// Get game state | |
const gameState = JSON.parse(window.localStorage.gameState); | |
// Close overlay if game status is in progress | |
if (gameState.gameStatus === "IN_PROGRESS") { | |
const overlay = document.querySelector("game-app").shadowRoot.querySelector("game-theme-manager game-modal").shadowRoot.querySelector(".overlay"); | |
overlay.click(); | |
} | |
// Make sure solution is loaded in local storage | |
const solution = JSON.parse(window.localStorage.gameState).solution; | |
if (!solution || solution.length === 0) { | |
return setTimeout(winAtWordle, 100); | |
} | |
// Win the game 😎 | |
solution.split("").forEach(function (letter) { | |
window.dispatchEvent(new KeyboardEvent("keydown", { key: letter })); | |
}); | |
window.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter" })); | |
console.log( | |
"%c 🤩 Congratulations! 🤩", | |
"padding: 1rem 2rem; font-weight: bold; font-size: 30px;color: red; text-shadow: 3px 3px 0 rgb(217,31,38) , 6px 6px 0 rgb(226,91,14) , 9px 9px 0 rgb(245,221,8) , 12px 12px 0 rgb(5,148,68) , 15px 15px 0 rgb(2,135,206) , 18px 18px 0 rgb(4,77,145) , 21px 21px 0 rgb(42,21,113)" | |
); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment