Wordle Autocomplete

Complete the current Wordle with just the click of a button

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Wordle Autocomplete
// @namespace    https://spin.rip/
// @version      1.0
// @description  Complete the current Wordle with just the click of a button
// @author       Spinfal
// @match        https://www.nytimes.com/games/wordle/index.html
// @icon         https://www.google.com/s2/favicons?domain=nytimes.com
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    const img = document.createElement("img");
    img.src = "https://cdn.spin.rip/r/cheat.png";
    img.setAttribute("style", "filter: invert(100%); width: 1.48em; height: 1.48em; padding-left: 0.4em; cursor: pointer;");
    img.setAttribute("aria-label", "Run Cheat");

    window.onload = () => {
        const solution = JSON.parse(localStorage.getItem('nyt-wordle-state')).solution.split("");

        document.querySelector("body > game-app").shadowRoot.querySelector("game-theme-manager > header > div.menu-right").appendChild(img);

        document.querySelector("body > game-app").shadowRoot.querySelector("game-theme-manager > header > div.menu-right > img").addEventListener("click", () => {
            document.querySelector("body > game-app").shadowRoot.querySelector("game-theme-manager > header > div.title").innerText = " Wordle owo ";
            solution.forEach(letter => {
                clickKey(letter);
            });
        });
    }

    function clickKey(data) {
        document.querySelector("body > game-app").shadowRoot.querySelector("#game > game-keyboard").shadowRoot.querySelector("#keyboard").querySelector(`[data-key=${data}]`).click();
    }
})();