Skip to content

Instantly share code, notes, and snippets.

@WebReflection
Last active January 21, 2022 11:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WebReflection/31b03c170546fc05e426fd73d2b7abb2 to your computer and use it in GitHub Desktop.
Save WebReflection/31b03c170546fc05e426fd73d2b7abb2 to your computer and use it in GitHub Desktop.
Create wordle report

Apparently there's no share button after wordling in my browsers, so I created this copy/paste JS to put in console, which will produce an output like:

Wordle 212 4/6

β¬›β¬›πŸŸ¨β¬›πŸŸ¨
πŸŸ¨πŸŸ¨πŸŸ¨πŸŸ¨β¬›
πŸŸ©πŸŸ¨β¬›πŸŸ¨πŸŸ¨
🟩🟩🟩🟩🟩

The script:

(function($$, $ = (Q, P) => $$(Q, P)[0]) {
  const {shadowRoot: app} = $('game-app');
  $('#settings-button', app).click();
  const page = $('game-page', app);
  const {textContent: num} = $('#puzzle-number', $('game-settings', page).shadowRoot);
  $('game-icon', page.shadowRoot).click();
  const rows = $$('game-row', $('game-theme-manager', app));
  const wordle = [];
  for (const {shadowRoot} of rows) {
    const row = [];
    for (const tile of $$('game-tile', shadowRoot)) {
      // for a big screenshot instead uncomment following 2 lines
      // tile.shadowRoot.appendChild(document.createElement('style')).textContent =
      //   '*{color:transparent !important;}';
      switch (tile.getAttribute('evaluation')) {
        case 'absent':
          row.push('⬛️');
          break;
        case 'present':
          row.push('🟨');
          break;
        case 'correct':
          row.push('🟩');
          break;
      }
    }
    wordle.push(row.join(''));
    if (row.every(score => score === '🟩'))
      break;
  }
  console.log([
    `Wordle ${num.slice(1)} ${wordle.length}/${rows.length}`,
    '',
  ].concat(wordle).join('\n'));
}((Q, P) => (P || document).querySelectorAll(Q)));

Also feel free to learn new words while playing, through this super handy tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment