TrueBonus Auto Attack + Refresh

Auto login, auto attack at max energy and refresh every minute

目前為 2025-12-18 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         TrueBonus Auto Attack + Refresh
// @namespace    https://truebonus.ru/
// @version      1.1
// @description  Auto login, auto attack at max energy and refresh every minute
// @author       Rubystance
// @license      MIT
// @match        https://truebonus.ru/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    const EMAIL = "YOUR_EMAIL_HERE";
    const MAX_ENERGY_TEXT = "Attack (20)";
    const REFRESH_TIME = 60000; // 1 minute

    function waitFor(selector, callback, interval = 300) {
        const timer = setInterval(() => {
            const el = document.querySelector(selector);
            if (el) {
                clearInterval(timer);
                callback(el);
            }
        }, interval);
    }

    function autoRefresh() {
        setTimeout(() => {
            location.reload();
        }, REFRESH_TIME);
    }

    // Login / Register page
    if (location.pathname === "/" || location.pathname === "/index.php") {
        waitFor('input[name="email"]', (input) => {
            const form = input.closest('form');
            const button = form?.querySelector('button[type="submit"]');

            input.focus();
            input.value = EMAIL;
            input.dispatchEvent(new Event('input', { bubbles: true }));
            input.dispatchEvent(new Event('change', { bubbles: true }));

            if (button) {
                setTimeout(() => button.click(), 500);
            }
        });
    }

    // Dashboard
    if (location.pathname === "/dashboard") {

        waitFor('#attack-btn', (attackBtn) => {

            const tryAttack = () => {
                if (
                    attackBtn.innerText.includes(MAX_ENERGY_TEXT) &&
                    !attackBtn.disabled
                ) {
                    attackBtn.click();
                }
            };

            // Initial attempt
            tryAttack();

            // Real-time observer
            const observer = new MutationObserver(tryAttack);
            observer.observe(attackBtn, {
                childList: true,
                subtree: true,
                characterData: true,
                attributes: true
            });

            // Force refresh every minute
            autoRefresh();
        });
    }

})();