ZedCity-Move Scavenge Button

Move the Scavenge button next to the Go Back button on page load & click

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         ZedCity-Move Scavenge Button
// @namespace    http://tampermonkey.net/
// @version      1.9.3
// @description  Move the Scavenge button next to the Go Back button on page load & click
// @author       YoYo
// @license      MIT
// @match        https://www.zed.city/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=zed.city
// @grant        none
// ==/UserScript==

(function() {
    'use strict';


    function moveScavengeButton() {
        
        const goBackButton = document.querySelector('.q-pb-sm button.q-btn--flat');
        const scavengeButton = document.querySelector('button[data-cy="scavenge-btn"]');

        if (goBackButton && scavengeButton) {
            console.log('🔍 Go Back button and Scavenge button found. Moving Scavenge button...');

            // Ensure it doesn't get duplicated by checking if it's already moved
            if (goBackButton.nextSibling !== scavengeButton) {
                goBackButton.parentElement.insertBefore(scavengeButton, goBackButton.nextSibling);
                console.log('✅ Scavenge button successfully moved next to Go Back.');
            }
        } else {
            console.log('⚠️ Go Back or Scavenge button not found. Will check again on next click.');
        }
    }

    // Function to wait for the Scavenge button to exist, then move it
    function waitForScavengeButton() {
        const checkInterval = setInterval(() => {
            const scavengeButton = document.querySelector('button[data-cy="scavenge-btn"]');
            if (scavengeButton) {
                console.log("✅ Scavenge button detected! Moving it now...");
                moveScavengeButton();
                clearInterval(checkInterval);
            }
        }, 100); // Check every 100ms until the button appears
    }

    // Run the function on page load
    window.addEventListener('load', () => {
        console.log('🚀 Page loaded. Running initial check...');
        moveScavengeButton();
    });

    // Run the function on every click (ensures it works after clicking into "Forest", etc.)
    document.addEventListener('click', (event) => {
        console.log('🖱️ Click detected! Checking button positions...');

        // Start waiting for the Scavenge button to appear if it hasn't already
        waitForScavengeButton();
    });

})();