GC - Throw Slorg at Neofriend Button

Adds Throw at Neofriend action to inventory menu

目前為 2024-09-14 提交的版本,檢視 最新版本

// ==UserScript==
// @name         GC - Throw Slorg at Neofriend Button
// @namespace    https://greasyfork.org/en/users/1251911
// @version      0.2
// @description  Adds Throw at Neofriend action to inventory menu
// @author       Teffy
// @match        https://www.grundos.cafe/inventory/
// @match        www.grundos.cafe/inventory/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=grundos.cafe
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    document.querySelectorAll('.inv-dropdown-menu').forEach(menu => {
        if (menu.querySelector('p').textContent.trim() === "Slorg") {
            const button = menu.querySelector('button[onclick]');
            const id = button.getAttribute('onclick').match(/['"]([a-f0-9\-]+)['"]/)[1];

            const throwButton = document.createElement('button');
            throwButton.setAttribute('onclick', `window.open('/useobject/${id}/?action=throw', 'newwindow', 'width=425,height=600'); return false;`);
            throwButton.innerHTML = `
                <img src="https://grundoscafe.b-cdn.net/items/hall_petpet1.gif" alt="Throw Icon" class="dropdown-icon"> Throw at Neofriend
            `;

            const targetButton = Array.from(menu.querySelectorAll('button')).find(button =>
                button.textContent.includes("Send One as Gift") || button.textContent.includes("Send as Gift")
            );
            menu.insertBefore(throwButton, targetButton.nextSibling);
        }
    });
})();