TerriX Executor v2.6

Elite Intelligence Suite. Adds Threat Radar, Interest Sync, and Reactive Defense.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         TerriX Executor v2.6
// @namespace    http://tampermonkey.net/
// @version      2.6
// @description  Elite Intelligence Suite. Adds Threat Radar, Interest Sync, and Reactive Defense.
// @author       Assistant
// @match        *://territorial.io/*
// @match        *://everythingtt.github.io/TerriX-Client/*
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    const CLIENT_URL = "https://everythingtt.github.io/TerriX-Client/Territorial.io.html";

    // --- 1. SCRIPT LIBRARY (The Elite Tools) ---
    const SCRIPT_LIB = {
        ThreatRadar: `/* Threat Radar: Detects ships in Fog of War */
if(!window.radar_loop) {
    window.radar_loop = setInterval(() => {
        const { bN, aD, ag } = window.G;
        const myId = aD.ep;
        const ships = bN.y;
        for(let i=0; i < ships.mG; i++) {
            // Check destination of ship (logic simplified for brevity)
            const targetPlayer = ships.mK[i] >> 3; 
            if(targetPlayer === myId) {
                console.warn("⚠️ TERRIX RADAR: INCOMING SHIP DETECTED!");
                document.getElementById('tx-header').style.background = 'red';
                setTimeout(() => document.getElementById('tx-header').style.background = '', 500);
            }
        }
    }, 1000);
    alert("Threat Radar Active.");
} else { clearInterval(window.radar_loop); window.radar_loop = null; alert("Radar Disabled."); }`,

        InterestSync: `/* Interest Sync: Highlights the economic pulse */
const G = window.G;
let lastTroops = G.ag.h7[G.aD.ep];
window.interest_watch = setInterval(() => {
    const current = G.ag.h7[G.aD.ep];
    if (current > lastTroops + 100) { // Large jump detected (Interest)
        const indicator = document.createElement('div');
        indicator.style = "position:fixed; top:50%; left:50%; color:gold; font-size:40px; z-index:999999; transform:translate(-50%,-50%); pointer-events:none; font-weight:bold;";
        indicator.innerText = "💰 TICK";
        document.body.appendChild(indicator);
        setTimeout(() => indicator.remove(), 300);
    }
    lastTroops = current;
}, 50);
alert("Economic Sync Active.");`,

        AutoColonize: `/* Optimization for early game expansion */
if(!window.tx_loop) {
    window.tx_loop = setInterval(() => {
        const G = window.G;
        if (!G || !G.b8 || !G.b8.hV) return;
        if (G.ag.h7[G.aD.ep] > 2000) G.b8.hV.hc(250, 512); 
    }, 1200);
    alert("Auto-Colonizer: ON");
} else { clearInterval(window.tx_loop); window.tx_loop = null; alert("OFF"); }`
    };

    // --- 2. UI STYLES (Territorial Glass Theme) ---
    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(10, 10, 10, 0.95); border: 1.8px solid white; 
            display: none; flex-direction: column; color: white; box-shadow: 0 0 40px rgba(0,0,0,1);
        }
        #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: 900; letter-spacing: 2px;}
        #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; text-transform: uppercase; }
        .tx-btn:hover { background: #444; border-color: #00ff00; }
        .tx-btn.active { background: #006400; }
        .tx-btn.hook-btn { background: #4b3214; margin-top: auto; border-color: #ffd700; }
        .tx-btn.client-btn { background: #1a1aff; border-color: #fff; animation: tx_glow 1.5s infinite; }
        
        @keyframes tx_glow { 0% { box-shadow: 0 0 5px #1a1aff; } 50% { box-shadow: 0 0 20px #1a1aff; } 100% { box-shadow: 0 0 5px #1a1aff; } }

        #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;}

        #tx-chart, #tx-scripts { display: none; flex: 1; flex-direction: column; gap: 5px; overflow-y: auto; }
        .script-item { background: #111; border: 1.5px solid #444; padding: 10px; display: flex; justify-content: space-between; align-items: center; border-radius: 4px; }
        .script-info { font-size: 12px; font-weight: bold; color: #00d2ff; }

        /* Chart Styling */
        .bar-row { display: flex; align-items: center; gap: 10px; height: 28px; width: 100%; flex-shrink: 0; transition: transform 0.3s ease; }
        .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; left: 100%; margin-left: 10px; font-size: 10px; color: #00ff00; font-family: monospace; }
        
        .me-row .bar-name { color: #ffd700; font-weight: bold; }
        .me-row .bar-fill { background: #ffd700; border: 1px solid white; }
    `;
    document.documentElement.appendChild(style);

    // --- 3. CORE LOGIC & UI ---
    const trap = { ag: null, aD: null, b8: null, bf: null, al: null, bN: null };
    const createTrap = (prop, name) => {
        Object.defineProperty(Object.prototype, prop, {
            set: function(v) { this["_" + prop] = v; if (!trap[name]) trap[name] = this; },
            get: function() { return this["_" + prop]; },
            configurable: true
        });
    };
    ['h7', 'ag'], ['ep', 'aD'], ['hV', 'b8'], ['aCP', 'bf'], ['kw', 'al'], ['mG', 'bN'].forEach(t => createTrap(t[0], t[1]));

    const build = () => {
        const wrapper = document.createElement('div');
        wrapper.id = 'tx-wrapper';
        wrapper.innerHTML = `
            <div id="tx-toggle">TERRIX EXECUTOR v2.6</div>
            <div id="tx-gui">
                <div id="tx-header"><span>TERRIX <span style="color:#00ff00">ELITE</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">POWER INDEX</button>
                        <button class="tx-btn" id="nav-scripts">MODS</button>
                        <button class="tx-btn client-btn" onclick="window.open('${CLIENT_URL}')">🚀 PRO CLIENT</button>
                        <button class="tx-btn hook-btn" id="tx-hook">INJECT HOOK</button>
                    </div>
                    <div id="tx-main">
                        <textarea id="tx-editor" spellcheck="false">/* TerriX Elite Interface */</textarea>
                        <div id="tx-chart"></div>
                        <div id="tx-scripts">
                            <div class="script-item"><span class="script-info">Threat Radar (ESP)</span><button class="tx-btn" onclick="tx_load('ThreatRadar')">LOAD</button></div>
                            <div class="script-item"><span class="script-info">Interest Sync</span><button class="tx-btn" onclick="tx_load('InterestSync')">LOAD</button></div>
                            <div class="script-item"><span class="script-info">Auto-Colonizer</span><button class="tx-btn" onclick="tx_load('AutoColonize')">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">RUN SCRIPT</button>
                    <div style="font-size: 10px; color: #555;">STATUS: <span id="tx-stat" style="color:#ff4444">WAITING</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 navBtns = ['nav-editor', 'nav-chart', 'nav-scripts'];
        navBtns.forEach((id, i) => {
            document.getElementById(id).onclick = () => {
                navBtns.forEach(b => document.getElementById(id).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 };
                this.innerText = "HOOKED"; this.style.background = "#008000";
                document.getElementById('tx-stat').innerText = "CONNECTED";
                document.getElementById('tx-stat').style.color = "#00ff00";
            } else alert("Error: Engine Not Found.");
        };

        document.getElementById('tx-execute').onclick = () => { try { new Function(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(); };

        // Draggable
        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();

    // --- 4. LEADERBOARD ---
    const bars = {};
    setInterval(() => {
        if (!window.G || document.getElementById('tx-chart').style.display !== 'flex') return;
        const { ag, aD } = window.G;
        const myId = aD ? aD.ep : -1;
        let players = [];
        for (let i = 0; i < 512; i++) {
            if (ag.gt[i] > 0) {
                const pwr = (ag.gt[i] * 10) + (ag.h7[i] / 50);
                players.push({ id: i, name: ag.zU[i] || "Bot", val: pwr, isMe: i === myId });
            }
        }
        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>`;
                document.getElementById('tx-chart').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);

})();