Evowars Auto-Claim Loop

Automated checking loop for resource rewards with a clean interface panel toggle.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Evowars Auto-Claim Loop
// @namespace    http://tampermonkey.net/
// @version      1.7
// @description  Automated checking loop for resource rewards with a clean interface panel toggle.
// @author       OpenSource
// @match        https://evowars.io/*
// @grant        none
// ==/UserScript==

(function () {
'use strict';

let loopActive = false;
let loopInterval = null;

// ------------------------------------------------------
// BUILD INTERFACE PANEL WITH TOGGLE BUTTON
// ------------------------------------------------------
function initLoopPanel() {
    if (document.getElementById('loop-claim-panel')) return;

    const style = document.createElement('style');
    style.innerHTML = `
        #loop-claim-panel {
            position: fixed; top: 15px; right: 15px; width: 160px;
            background: rgba(10, 10, 15, 0.95); border: 2px solid #10b981; border-radius: 8px;
            z-index: 999999; font-family: 'Segoe UI', sans-serif; padding: 10px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.8); display: flex; flex-direction: column; gap: 8px;
        }
        .hud-loop-title { font-size: 10px; font-weight: bold; text-align: center; color: #10b981; letter-spacing: 0.5px; }
        .loop-toggle-btn {
            background: #10b981; border: 1px solid #34d399; border-radius: 5px;
            color: #ffffff; font-size: 11px; font-weight: bold; padding: 8px 0;
            cursor: pointer; text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
            text-align: center;
            transition: background 0.1s;
        }
        .loop-toggle-btn.active {
            background: #ef4444; border-color: #f87171;
        }
        .loop-status { font-size: 9px; text-align: center; color: #9ca3af; }
    `;
    document.head.appendChild(style);

    const menu = document.createElement('div');
    menu.id = 'loop-claim-panel';
    menu.innerHTML = `
        <div class="hud-loop-title">Auto Farm</div>
        <button class="loop-toggle-btn" id="btn-loop-toggle">START</button>
        <div class="loop-status" id="txt-loop-status">OFF</div>
    `;
    document.body.appendChild(menu);

    document.getElementById('btn-loop-toggle').onclick = toggleAutoLoop;
}

// ------------------------------------------------------
// TOGGLE CONTROLLER
// ------------------------------------------------------
function toggleAutoLoop() {
    const btn = document.getElementById('btn-loop-toggle');
    const status = document.getElementById('txt-loop-status');

    loopActive = !loopActive;

    if (loopActive) {
        btn.textContent = "STOP AUTO-LOOP";
        btn.classList.add('active');
        status.textContent = "Status: Running...";

        // Run the scanner immediately, then check every 3 seconds
        attemptAutomaticClaims();
        loopInterval = setInterval(attemptAutomaticClaims, 3000);
    } else {
        btn.textContent = "START AUTO-LOOP";
        btn.classList.remove('active');
        status.textContent = "Status: Stopped";

        clearInterval(loopInterval);
    }
}

// ------------------------------------------------------
// LOOP EXECUTION ROUTINE
// ------------------------------------------------------
function attemptAutomaticClaims() {
    const overlayElements = Array.from(document.querySelectorAll('div.txt-shadow'));

    // Find elements matching the expected interactive UI text tags
    const targets = overlayElements.filter(el => {
        const text = el.textContent.trim().toUpperCase();
        return text === 'CLAIM' || text.includes('FREE');
    });

    if (targets.length === 0) return;

    const canvas = document.querySelector('canvas') || document.getElementById('canvas');
    if (!canvas) return;

    targets.forEach(label => {
        const labelRect = label.getBoundingClientRect();
        const clickX = labelRect.left + (labelRect.width / 2);
        const clickY = labelRect.top + (labelRect.height / 2);

        // Fire standard browser interaction events down to the canvas space coordinates
        ['mousemove', 'mousedown', 'mouseup', 'click'].forEach(eventType => {
            const isUp = eventType === 'mouseup' || eventType === 'click';
            canvas.dispatchEvent(new MouseEvent(eventType, {
                bubbles: true,
                cancelable: true,
                view: window,
                button: 0,
                buttons: isUp ? 0 : 1,
                clientX: clickX,
                clientY: clickY,
                screenX: clickX,
                screenY: clickY
            }));
        });
    });
}

// ------------------------------------------------------
// INITIALIZE INITIAL PANEL LOOP
// ------------------------------------------------------
const checkLoop = setInterval(() => {
    if (document.body) {
        clearInterval(checkLoop);
        initLoopPanel();
    }
}, 500);
})();