Honeygain Auto Click

Automatically click a button after the page has finished loading.

As of 2023-09-17. See the latest version.

// ==UserScript==
// @name         Honeygain Auto Click
// @namespace    http://tampermonkey.net/
// @version      0.6.1
// @description  Automatically click a button after the page has finished loading.
// @author       Tiger
// @match        https://dashboard.honeygain.com/
// @grant        none
// @license      AGPL license
// ==/UserScript==

(function() {
    'use strict';

    // Function to click the button
    function clickLuckyPotButton() {
        const className = 'sc-jcBMHH cUggGY';
        const elements = document.querySelectorAll('.${className}');
        const button = document.querySelector('button.sc-gisvNi ceucEs');
        elements.forEach(element => {
            // Find all buttons within the element
            const buttons = element.querySelectorAll('button');
            // Click each button
            buttons.forEach(button => {
                if (button) {
                    button.click();
                    //Double check the exsitence of click button
                    if (button) {
                        window.location.reload();
                    }
                }else{
                    startRandomReloadTimer();
                }
            });
        });
    }
    // Refresh the page with random time between 1 to 2 hours after clicking the button
    function startRandomReloadTimer() {
        const minReloadInterval = 60*60*1000; // 1 hour in milliseconds
        const maxReloadInterval = 2*60*60*1000; // 2 hours in milliseconds
        const reloadInterval = Math.random() * (maxReloadInterval - minReloadInterval) + minReloadInterval;
        setTimeout(() => window.location.reload(), reloadInterval);
    }

    setTimeout(clickLuckyPotButton, 3000);
})();