Knolix Auto BTC Tree Collector (FIXED)

Automatically clicks the BTC tree when ready and returns to home after harvest

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Knolix Auto BTC Tree Collector (FIXED)
// @namespace    http://tampermonkey.net/
// @version      2.0
// @author       Rubystance
// @description  Automatically clicks the BTC tree when ready and returns to home after harvest
// @match        https://knolix.com/*
// @license      MIT
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    const TOTAL_BITCOINS = 60;
    const CHECK_INTERVAL = 60000;

    function allBitcoinsReady() {
        for (let i = 0; i < TOTAL_BITCOINS; i++) {
            const el = document.getElementById(`bitcoin${i}`);
            if (!el || el.style.width !== '60px' || el.style.height !== '60px') {
                return false;
            }
        }
        return true;
    }

    function tryClickTree() {
        const tree = document.getElementById('btctree');
        if (tree && allBitcoinsReady()) {
            console.log("[Knolix] All bitcoins are fully grown. Clicking the tree...");
            tree.click();
        } else {
            console.log("[Knolix] Bitcoins are not fully grown yet.");
        }
    }

    function clickReturnHome() {
        const homeBtn = document.querySelector('a.navlink.w-nav-link[href="/"]');
        if (homeBtn) {
            console.log("[Knolix] Returning to home page...");
            homeBtn.click();
        } else {
            console.log("[Knolix] Home button not found.");
        }
    }

    function isHomePage() {
        return window.location.pathname === "/";
    }

    function isHarvestPage() {
        return window.location.pathname.startsWith("/harvest.php");
    }

    setInterval(() => {
        if (isHomePage()) {
            tryClickTree();
        }
    }, CHECK_INTERVAL);

    if (isHarvestPage()) {
        console.log("[Knolix] Harvest page detected. Waiting 3 seconds before returning...");
        setTimeout(clickReturnHome, 3000);
    }
})();