Grundo's Cafe (GC) - Wishing Well Ranked Autofill

Autofills the wishing well donation amount to 25. Compares your list of wishes to the most recently granted wishes, and chooses the first one that hasn't been granted.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Grundo's Cafe (GC) - Wishing Well Ranked Autofill
// @version      1
// @description  Autofills the wishing well donation amount to 25. Compares your list of wishes to the most recently granted wishes, and chooses the first one that hasn't been granted.
// @author       Chatgpt
// @match        https://grundos.cafe/wishing/
// @match        https://www.grundos.cafe/wishing/
// @license      MIT

// @namespace https://greasyfork.org/users/1519743
// ==/UserScript==

// Checks the most recently granted wishes, add more backup wishes by adding "item"
var wishes = [
    "Blue Draik Egg",
    "Yellow Draik Egg",
    "Red Draik Egg",
    "Green Draik Egg",
];

(function () {
    'use strict';

    if (window.location.href.match('grundos.cafe/wishing/')) {
        let donation = document.querySelector('[name="donation"]');
        if (donation) {
            // Adjust donation value here
            donation.value = 25;
        }

        let wish = document.querySelector('[name="wish"]');
        if (wish) {
            // Checks the most recently granted wishes
            const table = document.querySelector('table');
            let recentWishes = [];
            if (table) {
                const rows = Array.from(table.querySelectorAll('tr')).slice(0, 15);
                recentWishes = rows.flatMap(row =>
                    Array.from(row.querySelectorAll('td')).map(td => td.textContent.trim())
                );
            }

            // Pick the first wish not in recently granted
            let chosenWish = wishes.find(w => !recentWishes.includes(w));

            // If somehow all are taken, fallback to first wish
            if (!chosenWish) {
                chosenWish = wishes[0];
            }

            wish.value = chosenWish;
            console.log("Wish set to:", chosenWish);

            wish.focus();
        }
    }
})();