TerriX Executor v2.8

Grandmaster Strategy Suite. Fixed 'Undefined 87' errors and stabilized GodBot.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         TerriX Executor v2.8
// @namespace    http://tampermonkey.net/
// @version      2.8.1-S
// @description  Grandmaster Strategy Suite. Fixed 'Undefined 87' errors and stabilized GodBot.
// @author       Assistant
// @match        *://territorial.io/*
// @match        *://everythingtt.github.io/TerriX-Client/*
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    // --- 1. CORE ENGINE TRAPS (Grandmaster Level) ---
    let trap = { ag: null, aD: null, b8: null, bf: null, al: null, bN: null };
    
    // Improved trap logic for v2.15.20 obfuscation
    const createTrap = (prop, name) => {
        Object.defineProperty(Object.prototype, prop, {
            set: function(v) { 
                this["_" + prop] = v; 
                if (!trap[name]) {
                    trap[name] = this;
                    // Auto-bridge arrays to window.G if they leak
                    if (name === 'ag' && v instanceof Uint32Array) trap.ag.h7 = v;
                }
            },
            get: function() { return this["_" + prop]; },
            configurable: true
        });
    };

    [['h7', 'ag'], ['ep', 'aD'], ['hV', 'b8'], ['aCP', 'bf'], ['kw', 'al'], ['mG', 'bN'], ['aHB', 'b0']].forEach(t => createTrap(t[0], t[1]));

    // --- 2. SCRIPT LIBRARY (Shielded Logic) ---
    const SCRIPT_LIB = {
        GodBot: `/* GodBot v1.1: Shielded Strategy Engine */
if(!window.godbot_loop) {
    window.godbot_loop = setInterval(() => {
        const G = window.G;
        // Defensive Check: Ensure all arrays are bridged
        if (!G || !G.ag || !G.ag.h7 || !G.ag.gt || !G.aD) return;
        
        const myId = G.aD.ep;
        if (G.ag.mz[myId] === 0) return;

        const myTroops = G.ag.h7[myId];
        const myPixels = G.ag.gt[myId];
        
        // 1. Expansion Logic (Neutral Land)
        const neutralId = G.aD.f2 || 512;
        if (myTroops > (myPixels * 2.2)) {
            G.b8.hV.hc(280, neutralId); 
        }

        // 2. Attack Logic (Neighbor Scan)
        if (myTroops > (myPixels * 4.5)) {
            let targetId = -1;
            let minPixels = Infinity;

            for (let i = 0; i < (G.aD.f2 || 512); i++) {
                // Defensive check for enemy existence
                if (i !== myId && G.ag.mz && G.ag.mz[i] !== 0 && G.ag.gt[i] > 0) {
                    if (G.ag.gt[i] < minPixels) {
                        minPixels = G.ag.gt[i];
                        targetId = i;
                    }
                }
            }
            if (targetId !== -1) G.b8.hV.hc(120, targetId);
        }

        // 3. Auto-Peace Logic
        if (G.ag.gt[myId] > (G.aD.kA * 0.52)) G.b8.hV.ht(1);

    }, 1100);
    console.log("TerriX: GodBot Initialized.");
} else { clearInterval(window.godbot_loop); window.godbot_loop = null; console.log("GodBot Stopped."); }`,

        ThreatRadar: `/* Ship Warning System */
if(!window.radar_loop) {
    window.radar_loop = setInterval(() => {
        const G = window.G;
        if(!G.bN || !G.bN.y) return;
        const ships = G.bN.y;
        for(let i=0; i < ships.mG; i++) {
            if((ships.mK[i] >> 3) === G.aD.ep) {
                document.getElementById('tx-header').style.background = 'red';
                setTimeout(() => document.getElementById('tx-header').style.background = '', 200);
            }
        }
    }, 500);
    alert("Radar Active");
} else { clearInterval(window.radar_loop); window.radar_loop = null; alert("Radar Off"); }`
    };

    // --- 3. UI STYLES ---
    const style = document.createElement('style');
    style.innerHTML = `
        #tx-wrapper { position: fixed; top: 0; left: 0; width: 0; height: 0; z-index: 2147483647; font-family: 'system-ui', sans-serif; }
        #tx-gui {
            position: fixed; top: 100px; left: 100px; width: 680px; height: 480px;
            background: rgba(0, 0, 0, 0.95); border: 1.8px solid white; 
            display: none; flex-direction: column; color: white; box-shadow: 10px 10px 0px rgba(0,0,0,0.5);
        }
        #tx-header { padding: 12px 20px; background: rgba(30, 30, 30, 1); display: flex; justify-content: space-between; cursor: move; border-bottom: 1.8px solid white; font-weight: bold; font-size: 14px; }
        #tx-body { display: flex; flex: 1; overflow: hidden; }
        #tx-sidebar { width: 160px; background: rgba(15, 15, 15, 1); border-right: 1.8px solid white; padding: 15px; display: flex; flex-direction: column; gap: 10px; }
        #tx-main { flex: 1; display: flex; flex-direction: column; padding: 15px; background: #000; }
        #tx-editor { flex: 1; background: #050505; color: #00ff00; border: 1.5px solid #333; padding: 15px; font-family: 'Consolas', monospace; resize: none; outline: none; font-size: 13px; }
        .tx-btn { padding: 8px; background: rgba(50, 50, 50, 0.9); border: 1.8px solid white; color: white; cursor: pointer; font-size: 11px; font-weight: bold; }
        .tx-btn:hover { background: #444; }
        .tx-btn.active { background: #006400; }
        #tx-toggle { position: fixed; top: 0; left: 50%; transform: translateX(-50%); padding: 5px 30px; background: #005000; color: white; border: 1.8px solid white; border-top: none; border-radius: 0 0 10px 10px; cursor: pointer; font-weight: bold; z-index: 1000003; font-size: 10px;}
        .script-item { background: #111; border: 1.8px solid white; padding: 10px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px;}
        
        .bar-row { display: flex; align-items: center; gap: 10px; height: 28px; width: 100%; flex-shrink: 0; }
        .bar-rank { width: 35px; font-size: 12px; color: #777; font-weight: bold; text-align: right; }
        .bar-name { width: 140px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #eee; }
        .bar-track { flex: 1; background: #111; height: 16px; border: 1px solid #333; position: relative; }
        .bar-fill { height: 100%; width: 0%; background: #2e7d32; transition: width 0.4s ease; border-right: 2px solid #fff; }
        .bar-val { position: absolute; right: 5px; font-size: 10px; color: white; line-height: 16px; font-weight: bold;}
        .me-row { color: #ffd700 !important; }
        .me-row .bar-fill { background: #ffd700; border: 1px solid white; }
    `;
    document.documentElement.appendChild(style);

    // --- 4. UI CONSTRUCTION ---
    const build = () => {
        const wrapper = document.createElement('div');
        wrapper.id = 'tx-wrapper';
        wrapper.innerHTML = `
            <div id="tx-toggle">TERRIX MENU</div>
            <div id="tx-gui">
                <div id="tx-header"><span>TERRIX <span style="color:#ffd700">GRANDMASTER</span></span> <span id="tx-close" style="cursor:pointer">✕</span></div>
                <div id="tx-body">
                    <div id="tx-sidebar">
                        <button class="tx-btn active" id="nav-editor">EDITOR</button>
                        <button class="tx-btn" id="nav-chart">LEADERBOARD</button>
                        <button class="tx-btn" id="nav-scripts">GOD BOT</button>
                        <button class="tx-btn" style="margin-top:auto; border-color:#3a47ff" onclick="window.open('https://everythingtt.github.io/TerriX-Client/Territorial.io.html')">🚀 PRO CLIENT</button>
                        <button class="tx-btn" id="tx-hook" style="background:#4b3214">INJECT HOOK</button>
                    </div>
                    <div id="tx-main">
                        <textarea id="tx-editor" spellcheck="false">/* TerriX Code Executor */</textarea>
                        <div id="tx-chart" style="display:none; flex-direction:column; gap:5px; overflow-y:auto;"></div>
                        <div id="tx-scripts" style="display:none; flex-direction:column; gap:5px; overflow-y:auto;">
                            <div class="script-item"><span style="color:gold; font-weight:bold;">GodBot v1.1</span><button class="tx-btn" onclick="tx_load('GodBot')">LOAD</button></div>
                            <div class="script-item"><span>Ship Radar (ESP)</span><button class="tx-btn" onclick="tx_load('ThreatRadar')">LOAD</button></div>
                        </div>
                    </div>
                </div>
                <div style="padding: 10px 20px; background: #0a0a0a; display: flex; justify-content: space-between; border-top: 1.8px solid white;">
                    <button class="tx-btn" style="background:#008000; border:none; padding: 5px 20px;" id="tx-execute">EXECUTE</button>
                    <div id="tx-stat" style="font-size: 10px; color: #888;">STATUS: <span style="color:#f44">OFFLINE</span></div>
                </div>
            </div>
        `;
        document.documentElement.appendChild(wrapper);

        const gui = document.getElementById('tx-gui');
        document.getElementById('tx-toggle').onclick = () => gui.style.display = gui.style.display === 'flex' ? 'none' : 'flex';
        document.getElementById('tx-close').onclick = () => gui.style.display = 'none';

        const tabs = [document.getElementById('tx-editor'), document.getElementById('tx-chart'), document.getElementById('tx-scripts')];
        const navs = ['nav-editor', 'nav-chart', 'nav-scripts'];

        navs.forEach((id, i) => {
            document.getElementById(id).onclick = () => {
                navs.forEach(n => document.getElementById(n).classList.remove('active'));
                tabs.forEach(t => t.style.display = 'none');
                document.getElementById(id).classList.add('active');
                tabs[i].style.display = i === 0 ? 'block' : 'flex';
            };
        });

        document.getElementById('tx-hook').onclick = function() {
            if (window.G || (trap.ag && trap.aD)) {
                window.G = window.G || { ...trap };
                // Final check for typed array bridging
                if (!window.G.ag.gt && trap.ag) window.G.ag.gt = trap.ag.gt;
                
                this.innerText = "HOOKED"; this.style.background = "green";
                document.getElementById('tx-stat').innerHTML = "HOOKED: <span style='color:lime'>ACTIVE</span>";
            } else alert("Error: Use TerriX Client on GitHub.");
        };

        document.getElementById('tx-execute').onclick = () => { try { eval(document.getElementById('tx-editor').value); } catch(e) { alert(e); } };
        window.tx_load = (k) => { document.getElementById('tx-editor').value = SCRIPT_LIB[k]; document.getElementById('nav-editor').click(); };

        let d = false, x, y;
        document.getElementById('tx-header').onmousedown = (e) => { d = true; x = e.clientX - gui.offsetLeft; y = e.clientY - gui.offsetTop; };
        window.onmousemove = (e) => { if (d) { gui.style.left = (e.clientX - x) + 'px'; gui.style.top = (e.clientY - y) + 'px'; } };
        window.onmouseup = () => d = false;
    };

    build();

    // --- 5. LEADERBOARD ---
    const bars = {};
    setInterval(() => {
        const container = document.getElementById('tx-chart');
        if (!container || container.style.display !== 'flex' || !window.G) return;
        const { ag, aD } = window.G;
        if (!ag.gt) return;

        let players = [];
        for (let i = 0; i < 512; i++) {
            if (ag.gt[i] > 0) {
                const score = (ag.gt[i] * 10) + (ag.h7[i] / 50);
                players.push({ id: i, name: ag.zU[i] || "Bot", val: score, isMe: i === aD.ep });
            }
        }
        players.sort((a, b) => b.val - a.val);
        const top = players.slice(0, 15);
        const max = top[0]?.val || 1;

        top.forEach((p, idx) => {
            if (!bars[p.id]) {
                const r = document.createElement('div');
                r.className = 'bar-row';
                r.innerHTML = `<div class="bar-rank"></div><div class="bar-name"></div><div class="bar-track"><div class="bar-fill"></div><span class="bar-val"></span></div>`;
                container.appendChild(r);
                bars[p.id] = r;
            }
            const r = bars[p.id];
            r.style.display = 'flex'; r.style.order = idx;
            r.className = p.isMe ? 'bar-row me-row' : 'bar-row';
            r.querySelector('.bar-rank').innerText = "#" + (idx + 1);
            r.querySelector('.bar-name').innerText = p.name;
            r.querySelector('.bar-fill').style.width = (p.val / max * 100) + '%';
            r.querySelector('.bar-val').innerText = Math.floor(p.val).toLocaleString();
        });
        Object.keys(bars).forEach(id => { if (!top.find(p => p.id == id)) bars[id].style.display = 'none'; });
    }, 500);

})();