Last active
December 26, 2021 03:14
-
-
Save marcus-crane/9d33a830fbea7939daeec6599088f9cb to your computer and use it in GitHub Desktop.
A small devtools sketch for reflecting the Daily Wordle grid as a group of emojis
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
let tiles = [] | |
document.querySelector("game-app").$board.querySelectorAll("game-row").forEach(row => { | |
let rowTiles = [] | |
row.$tiles.forEach(tile => rowTiles.push(tile._state)) | |
tiles.push(rowTiles) | |
}) | |
for (let row of tiles) { | |
let rowString = "" | |
for (let tile of row) { | |
switch (tile) { | |
case 'absent': | |
rowString += '⬛️ ' | |
break | |
case 'present': | |
rowString += '🟨 ' | |
break | |
case 'correct': | |
rowString += '🟩 ' | |
break | |
default: | |
// This will just print nothing for empty tiles | |
break | |
} | |
} | |
if (rowString) { | |
console.log(rowString) | |
} | |
} |
Annoying Daily Wordle uses custom web components so these tiles are technically within the Shadow DOM but there are some handy helper variables defined :)
Daily Wordle now has official support for sharing your game state when you finish an entry so this is now redundant.
I also realised in hindsight that game state probably lives in local storage so here's an even shorter snippet:
let tiles = JSON.parse(window.localStorage.gameState).evaluations.filter(row => row !== null)
for (let row of tiles) {
let rowString = ""
for (let tile of row) {
switch (tile) {
case 'absent':
rowString += '⬛️ '
break
case 'present':
rowString += '🟨 '
break
case 'correct':
rowString += '🟩 '
break
default:
// This will just print nothing for empty tiles
break
}
}
if (rowString) {
console.log(rowString)
}
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example of this run against https://www.dailywordle.com