Auto Reload on Stake.com - CodeStats edition

Automatically claims rewards on Stake.com by sequentially clicking VIP Reward → Claim Reload → Return to Rewards. The script starts after a short page-load delay, mimics human behavior with random delays, occasional skipped cycles, and subtle mouse/scroll movements. FREE BONUS CODES @ https://t.me/codestats2 SOL: FVDejAWbUGsgnziRvFi4eGkJZuH6xuLviuTdi2g4Ut3o

// ==UserScript==
// @name         Auto Reload on Stake.com - CodeStats edition
// @description  Automatically claims rewards on Stake.com by sequentially clicking VIP Reward → Claim Reload → Return to Rewards. The script starts after a short page-load delay, mimics human behavior with random delays, occasional skipped cycles, and subtle mouse/scroll movements. FREE BONUS CODES @ https://t.me/codestats2   SOL: FVDejAWbUGsgnziRvFi4eGkJZuH6xuLviuTdi2g4Ut3o
// @author       CHUBB
// @namespace    https://t.me/codestats2
// @version      09.22.2025.002
// @match        https://stake.com/*
// @match        https://stake.us/*
// @match        https://stake.com/?tab=rewards&modal=vip
// @match        https://stake.us/?tab=rewards&modal=vip
// @run-at       document-idle
// @license      MIT
// ==/UserScript==

// ===== HUD SETUP =====
function setupHUD() {
    let hud = document.createElement("div");
    hud.id = "autoReloadHUD";
    hud.style.cssText = `
        position: fixed;
        bottom: 10px;
        right: 10px;
        width: 650px;
        max-height: 200px;
        overflow-y: auto;
        font-size: 13px;
        background: rgba(0,0,0,0.8);
        color: #0f0;
        padding: 10px;
        border-radius: 8px;
        font-family: monospace;
        z-index: 999999;
    `;
    hud.innerHTML = `<b>Auto Reload Bot</b><br><div id="hudLog"></div><div id="hudTimer"></div>`;
    document.body.appendChild(hud);
}
setupHUD();

function logHUD(msg) {
    let log = document.getElementById("hudLog");
    if (log) {
        let line = document.createElement("div");
        line.textContent = `[${new Date().toLocaleTimeString()}] ${msg}`;
        log.appendChild(line); // add new line at the bottom
        while (log.childNodes.length > 3) log.removeChild(log.firstChild); // trim from top
        log.scrollTop = log.scrollHeight; // auto-scroll to bottom
    }
    console.log(msg);
}



function updateTimer(ms) {
    let el = document.getElementById("hudTimer");
    if (!el) return;
    let sec = Math.floor(ms / 1000);
    let m = Math.floor(sec / 60);
    let s = sec % 60;
    el.textContent = `Next attempt in ${m}m ${s}s`;
}

// ===== CLICK FUNCTION =====
async function orderedClick(selector, retries = 5, interval = 3000) {
    for (let i = 0; i < retries; i++) {
        const el = document.querySelector(selector);
        if (el) {
            const delay = Math.floor(Math.random() * 2000) + 1000;
            await wait(delay);
            el.click();
            logHUD(`Clicked: ${selector} (after ${delay}ms)`);
            return true;
        }
        await wait(interval);
    }
    logHUD(`FAILED: ${selector}`);
    return false;
}

// ===== CLAIM FUNCTION =====
async function claimReload() {
    simulateMouseMove();

    await orderedClick('button[data-testid="progress-tab"]');
    await orderedClick('button[data-testid="rewards-tab"]');
    await orderedClick('button[data-testid="vip-reward-claim-reload"]');

    // The MONEY button
    const claimSuccess = await orderedClick('button[data-testid="claim-reload"]');

    if (claimSuccess) {
        // If we successfully clicked claim, we *must* try to wrap up
        const finalStep = await orderedClick('button[data-testid="return-to-rewards"]');
        if (!finalStep) {
            logHUD("Claimed reload but couldn't return → reloading page...");
            window.location.href = "https://stake.com/?tab=progress&modal=vip";
            return;
        }
    }

    simulateMouseMove();
    logHUD("Finished reload attempt.");
}


// ===== CYCLE FUNCTION =====
function startCycle() {
    const min = 10 * 60 * 1000;
    const max = 12 * 60 * 1000;
    const delay = Math.floor(Math.random() * (max - min + 1)) + min;

    let endTime = Date.now() + delay;
    let timer = setInterval(() => {
        let remaining = endTime - Date.now();
        if (remaining <= 0) {
            clearInterval(timer);
            return;
        }
        updateTimer(remaining);
    }, 1000);

    logHUD(`Next attempt scheduled in ${(delay / 60000).toFixed(2)} minutes`);

    setTimeout(async () => {
        await claimReload();
        startCycle();
    }, delay);
}

// ===== UTILITIES =====
function simulateMouseMove() {
    const simElm = document.documentElement;
    const simMouseMove = new Event('mousemove', { bubbles: true });
    simElm.dispatchEvent(simMouseMove);
}

function wait(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}

// ===== INITIAL RUN =====
(function firstRun() {
    const firstDelay = Math.floor(Math.random() * 5000) + 5000;
    logHUD(`First attempt in ${(firstDelay / 1000).toFixed(1)}s`);
    setTimeout(async () => {
        await claimReload();
        startCycle();
    }, firstDelay);
})();