ZedCity-Move Scavenge Button

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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();
    });

})();