adminoo

testadmin

目前為 2025-06-27 提交的版本,檢視 最新版本

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.gf.qytechs.cn/scripts/540905/1614876/adminoo.js

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();
    }
})();
    

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址