[GC] Overfeed Preventer

Track pet bloat status and modify and notify if your pet is already bloated to prevent over-feeding

当前为 2025-03-03 提交的版本,查看 最新版本

// ==UserScript==
// @name         [GC] Overfeed Preventer
// @namespace    http://tampermonkey.net/
// @version      1.1
// @license      MIT
// @description  Track pet bloat status and modify and notify if your pet is already bloated to prevent over-feeding
// @author       Heda
// @match        https://www.grundos.cafe/itemview/*
// @match        https://www.grundos.cafe/useobject/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function getItemName() {
        let itemElement = [...document.querySelectorAll("div.flex-column.justify-center span")]
            .find(span => span.textContent.includes("Item"));
        return itemElement ? itemElement.textContent.replace("Item :", "").trim() : null;
    }

    function modifyPageForBloat() {
        if (localStorage.getItem("bloated") === "true" && localStorage.getItem("currentItem") !== "Bloatershroom") {
            document.querySelector("input#submit.form-control.flex-grow")?.remove();
            let itemActionSelect = document.querySelector("select#itemaction_select");
            if (itemActionSelect) {
                let alertDiv = document.createElement("div");
                alertDiv.style.cssText = "background:red;color:white;font-weight:bold;padding:10px;text-align:center;cursor:pointer;margin-top:10px;border-radius:5px;width:100%;max-width:400px;margin:auto;";
                alertDiv.innerHTML = "PET IS BLOATED <br> CLICK TO RESET IF THIS IS A MISTAKE";
                alertDiv.onclick = () => {
                    localStorage.setItem("bloated", "false");
                    alert("Bloat status reset.");
                    location.reload();
                };
                itemActionSelect.parentElement.insertAdjacentElement('afterend', alertDiv);
            }
        }
    }

    if (window.location.href.startsWith("https://www.grundos.cafe/itemview/")) {
        let itemName = getItemName();
        if (itemName) localStorage.setItem("currentItem", itemName);
        modifyPageForBloat();
    }

    if (window.location.href.startsWith("https://www.grundos.cafe/useobject/")) {
        let bodyText = document.body.textContent;
        if (bodyText.includes("and now is bloated")) localStorage.setItem("bloated", "true");
        else if (bodyText.includes("now is very full")) localStorage.setItem("bloated", "false");
    }
})();