A Crypto Miner (AB)

click claim button

// ==UserScript==
// @name         A Crypto Miner (AB)
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  click claim button
// @author       👽
// @match        https://acryptominer.io/user/faucet
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    function randomDelay(min, max) {
        return Math.floor(Math.random() * (max - min + 1)) + min;
    }

    function simulateClick(button) {
        // Repeat the event sequence multiple times for reliability
        for (let i = 0; i < 3; i++) {
            ['mouseover', 'mousedown', 'mouseup', 'click'].forEach(type => {
                button.dispatchEvent(new MouseEvent(type, {
                    view: window,
                    bubbles: true,
                    cancelable: true,
                    buttons: 1
                }));
            });
        }
    }

    function isVisible(el) {
        const style = window.getComputedStyle(el);
        return style.display !== 'none' && style.visibility !== 'hidden' && el.offsetParent !== null;
    }

    function waitForEnabledButton(id, callback) {
        const interval = setInterval(() => {
            const button = document.getElementById(id);
            if (button && isVisible(button) && !button.disabled) {
                clearInterval(interval);
                callback(button);
            }
        }, 300); // check every 300ms
    }

    window.addEventListener('load', () => {
        waitForEnabledButton('claim-button', (button) => {
            const firstDelay = randomDelay(10000, 13000);
            console.log(`First click in ${firstDelay}ms`);

            setTimeout(() => {
                console.log('Attempting first click...');
                simulateClick(button);

                setTimeout(() => {
                    console.log('Attempting second click...');
                    simulateClick(button);
                }, 2000); // second click 2s later

            }, firstDelay);
        });
    });
})();