Knolix Auto Click Bitcoin Tree (fixed)

Automatically clicks the bitcoin tree every 40 minutes with visibility check and delay.

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

// ==UserScript==
// @name         Knolix Auto Click Bitcoin Tree (fixed)
// @namespace    http://tampermonkey.net/
// @version      1.5
// @description  Automatically clicks the bitcoin tree every 40 minutes with visibility check and delay.
// @author       Rubystance
// @license      MIT
// @match        https://knolix.com/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    let clickedTree = false;

    function isTreeFull() {
        for (let i = 0; i < 60; i++) {
            const el = document.getElementById('bitcoin' + i);
            if (!el || el.offsetWidth === 0 || el.offsetHeight === 0) {
                return false;
            }
        }
        return true;
    }

    function tryClickTree() {
        const tree = document.getElementById('btctree');
        if (!tree) {
            console.log('[Knolix Auto] Tree element not found.');
            return;
        }

        const style = window.getComputedStyle(tree);
        const visible = style.display !== 'none' && style.visibility !== 'hidden' && tree.offsetParent !== null;

        if (!visible) {
            console.log('[Knolix Auto] Tree is not visible. Skipping click.');
            return;
        }

        if (!isTreeFull()) {
            console.log('[Knolix Auto] Tree is not full (missing or invisible bitcoins).');
            return;
        }

        if (clickedTree) {
            console.log('[Knolix Auto] Already clicked in this cycle. Waiting for the next 40min interval.');
            return;
        }

        console.log('[Knolix Auto] Tree is ready! Waiting 5 seconds before clicking...');
        setTimeout(() => {
            try {
                tree.click();
                clickedTree = true;
                console.log('[Knolix Auto] Clicked the tree successfully!');
            } catch (e) {
                console.error('[Knolix Auto] Failed to click the tree:', e);
            }
        }, 5000);
    }

    setInterval(() => {
        clickedTree = false;
        console.log('[Knolix Auto] New 40-minute cycle. Trying to click tree again...');
        tryClickTree();
    }, 2400000);

    window.addEventListener('load', () => {
        tryClickTree();
    });

})();