adminoo

testadmin

Versione datata 27/06/2025. Vedi la nuova versione l'ultima versione.

Questo script non dovrebbe essere installato direttamente. È una libreria per altri script da includere con la chiave // @require https://update.greasyfork.org/scripts/540905/1614876/adminoo.js

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

Tabs.AutoRoyalConquestTab = {
    tabOrder: 8002,
    tabLabel: 'Auto Royal Conquest',
    tabColor: 'green',
    myDiv: null,
    isInitialized: false,
    autoAttackInterval: null,

    init: function(div) {
        var t = this;
        t.myDiv = div;
        t.myDiv.style.display = 'none';
        t.isInitialized = true;
        t.updateStatus('Ready to automate Royal Conquest');
    },

    paint: function() {
        var t = this;
        if (!t.isInitialized) {
            t.updateStatus('Please initialize first');
            return;
        }

        var m = `
            <div class="divHeader" align="center">Auto Royal Conquest</div>
            <div class="monitorContainer">
                <div class="inputGroup">
                    <label for="troopCountInput">Troops per Attack:</label>
                    <input type="number" id="troopCountInput" class="btInput" value="41000" min="1" max="41000" />
                </div>
                <div class="inputGroup">
                    <button id="startAutoAttack" class="buttonv2 std green">Start Auto</button>
                    <button id="stopAutoAttack" class="buttonv2 std red">Stop</button>
                </div>
                <div id="autoConquestStatus" class="statusMessage"></div>
            </div>
        `;

        t.myDiv.innerHTML = m;

        // Add styles if needed (reuse from your existing style block or add new ones)

        $("#startAutoAttack", t.myDiv).click(function() {
            t.startAutoAttack();
        });
        $("#stopAutoAttack", t.myDiv).click(function() {
            t.stopAutoAttack();
        });
    },

    show: function() {
        var t = this;
        t.myDiv.style.display = 'block';
        t.paint();
        t.updateStatus('Ready to automate Royal Conquest');
    },

    hide: function() {
        var t = this;
        t.myDiv.style.display = 'none';
        t.stopAutoAttack();
        t.updateStatus('');
    },

    updateStatus: function(message) {
        var t = this;
        var statusEl = $("#autoConquestStatus", t.myDiv);
        statusEl.html(message);
        statusEl.css({
            'color': message.includes('Error') ? '#dc3545' : '#28a745',
            'background-color': message.includes('Error') ? '#f8d7da' : '#d4edda'
        });
    },

    startAutoAttack: function() {
        var t = this;
        if (t.autoAttackInterval) {
            t.updateStatus('Auto attack is already running');
            return;
        }
        var troopCount = parseInt($("#troopCountInput", t.myDiv).val(), 10) || 41000;
        t.updateStatus('Auto attack started');
        t.autoAttackInterval = setInterval(function() {
            try {
                t.performAttack(troopCount);
            } catch (e) {
                t.updateStatus('Error: ' + e.message);
            }
        }, 5000); // Attack every 5 seconds (adjust as needed)
    },

    stopAutoAttack: function() {
        var t = this;
        if (t.autoAttackInterval) {
            clearInterval(t.autoAttackInterval);
            t.autoAttackInterval = null;
            t.updateStatus('Auto attack stopped');
        }
    },

    performAttack: function(troopCount) {
        // This function should interact with the game's attack logic.
        // Example: fill troop inputs and click the attack button.
        // You may need to adjust selectors based on the actual game DOM.

        // Example for setting all available troops (adjust as needed):
        $(".troopInput").each(function() {
            $(this).val(troopCount);
        });

        // Click the attack button
        var attackBtn = $("button:contains('Attack')");
        if (attackBtn.length) {
            attackBtn[0].click();
            this.updateStatus('Attack sent with ' + troopCount + ' troops');
        } else {
            this.updateStatus('Error: Attack button not found');
        }
    }
};

// Register the tab with the game UI
(function() {
    function init() {
        var gameTabs = window.Tabs || (window.unsafeWindow && unsafeWindow.Tabs);
        if (gameTabs && gameTabs.addTab) {
            try {
                gameTabs.addTab(Tabs.AutoRoyalConquestTab);
                var originalShowTab = gameTabs.showTab;
                gameTabs.showTab = function(tab) {
                    originalShowTab.apply(this, arguments);
                    if (tab === 'AutoRoyalConquestTab') {
                        var tabDiv = document.getElementById('tab_AutoRoyalConquestTab');
                        if (tabDiv) {
                            if (!Tabs.AutoRoyalConquestTab.isInitialized) {
                                Tabs.AutoRoyalConquestTab.init(tabDiv);
                            }
                            Tabs.AutoRoyalConquestTab.paint();
                        }
                    }
                };
                return;
            } catch (e) {
                console.error('Error initializing AutoRoyalConquestTab:', e);
            }
        }
        setTimeout(init, 500);
    }
    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', init);
    } else {
        init();
    }
})();