Skip to content

Instantly share code, notes, and snippets.

@marcus-crane
Last active December 26, 2021 03:14
Show Gist options
  • Select an option

  • Save marcus-crane/9d33a830fbea7939daeec6599088f9cb to your computer and use it in GitHub Desktop.

Select an option

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
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)
}
}
@marcus-crane

Copy link
Copy Markdown
Author

Example of this run against https://www.dailywordle.com

Screen Shot 2021-12-16 at 9 54 16 AM

@marcus-crane

marcus-crane commented Dec 15, 2021

Copy link
Copy Markdown
Author

Annoying Daily Wordle uses custom web components so these tiles are technically within the Shadow DOM but there are some handy helper variables defined :)

@marcus-crane

Copy link
Copy Markdown
Author

Daily Wordle now has official support for sharing your game state when you finish an entry so this is now redundant.

@marcus-crane

Copy link
Copy Markdown
Author

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