Wordle Autocomplete

Complete the current Wordle with just the click of a button

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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();
    }
})();