FeyorraSite

Auto click checkbox, claim, refresh on images with randomized delays and inactivity refresh

// ==UserScript==
// @name         FeyorraSite
// @namespace    http://tampermonkey.net/
// @version      1.6
// @description  Auto click checkbox, claim, refresh on images with randomized delays and inactivity refresh
// @author       👽
// @match        https://feyorra.site/member/faucet
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    const delay = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;

    const targetWidthVerified = 76;
    const targetHeightVerified = 23;
    const targetWidthRefresh = 349;
    const targetHeightRefresh = 23;

    let alreadyChecked = false;
    let alreadyClicked = false;
    let alreadyRefreshed = false;

    let lastActionTimestamp = Date.now();

    // Helper: simulate a real user click
    function simulateClick(element) {
        if (!element) return false;
        const event = new MouseEvent('click', {
            view: window,
            bubbles: true,
            cancelable: true
        });
        return element.dispatchEvent(event);
    }

    // Step 1: On script load, wait 10–15s then click checkbox
    setTimeout(() => {
        const checkbox = document.querySelector('#verifyCheckbox');
        if (checkbox && !checkbox.checked) {
            simulateClick(checkbox);
            lastActionTimestamp = Date.now();
        }
        alreadyChecked = true;
    }, delay(10000, 15000)); // 10–15 seconds

    // Step 2: Watch for images and take actions
    function checkImagesBySize() {
        const images = document.querySelectorAll('img');

        for (const img of images) {
            if (!img.complete || img.naturalWidth === 0) continue;

            const width = img.naturalWidth;
            const height = img.naturalHeight;

            // Action 1: Claim if 76x23 image found
            if (!alreadyClicked && width === targetWidthVerified && height === targetHeightVerified) {
                const randomDelay = delay(3000, 7000); // 3–7 seconds
                alreadyClicked = true;

                setTimeout(() => {
                    const claimBtn = document.querySelector('button#ClaimBtn');
                    if (claimBtn) {
                        simulateClick(claimBtn);
                        lastActionTimestamp = Date.now();
                    }
                }, randomDelay);
            }

            // Action 2: Refresh if 349x23 image found
            if (!alreadyRefreshed && width === targetWidthRefresh && height === targetHeightRefresh) {
                const randomDelay = delay(5000, 8000); // 5–8 seconds
                alreadyRefreshed = true;

                setTimeout(() => {
                    location.reload();
                }, randomDelay);

                lastActionTimestamp = Date.now();
            }
        }
    }

    // Step 3: Inactivity refresh after 30 seconds
    setInterval(() => {
        const now = Date.now();
        if (now - lastActionTimestamp > 30000) { // 30 seconds
            location.reload();
        }
    }, 5000); // check every 5 seconds

    // Start checking images every second
    setInterval(checkImagesBySize, 1000);
})();