TerriX Executor v2.7

Automated Pro-Play Suite. Introduces GodBot v1.0 for testing automated win-path strategies.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey, Greasemonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Userscripts.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een gebruikersscriptbeheerder nodig.

(Ik heb al een user script manager, laat me het downloaden!)

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

(Ik heb al een beheerder - laat me doorgaan met de installatie!)

// ==UserScript==
// @name         TerriX Executor v2.7
// @namespace    http://tampermonkey.net/
// @version      2.7.1
// @description  Automated Pro-Play Suite. Introduces GodBot v1.0 for testing automated win-path strategies.
// @author       Assistant
// @match        *://territorial.io/*
// @match        *://everythingtt.github.io/TerriX-Client/*
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    // --- 1. SCRIPT LIBRARY (The GodBot Core) ---
    const SCRIPT_LIB = {
        GodBot: `/* GodBot v1.0: Automated Strategy Engine */
if(!window.godbot_loop) {
    window.godbot_loop = setInterval(() => {
        const G = window.G;
        if (!G || !G.b8 || !G.ag) return;
        
        const myId = G.aD.ep;
        const myTroops = G.ag.h7[myId];
        const myPixels = G.gt[myId];
        
        // 1. Check if we are alive
        if (G.ag.mz[myId] === 0) return;

        // 2. Expansion Phase (Neutral Land)
        const neutralId = G.aD.f2;
        if (myTroops > (myPixels * 2.5)) { // Only attack if above Interest Floor
            console.log("GodBot: Expanding...");
            G.b8.hV.hc(250, neutralId); // 25% Wave
        }

        // 3. Combat Phase (Neighbor Scan)
        if (myTroops > (myPixels * 5)) { // High Aggression Threshold
            let targetId = -1;
            let minPixels = Infinity;

            for (let i = 0; i < G.aD.f2; i++) {
                if (i !== myId && G.ag.mz[i] !== 0) {
                    if (G.ag.gt[i] < minPixels && G.ag.gt[i] > 0) {
                        minPixels = G.ag.gt[i];
                        targetId = i;
                    }
                }
            }

            if (targetId !== -1) {
                console.log("GodBot: Aggressing Weakest Enemy: " + G.ag.zU[targetId]);
                G.b8.hV.hc(150, targetId); // 15% Precise Poke
            }
        }
        
        // 4. Auto-Diplomacy (Peace Voting)
        if (myPixels > (G.aD.kA * 0.51)) { // If we own >51% of land
             G.b8.hV.ht(1); // Vote Peace
        }

    }, 1200);
    alert("GodBot v1.0 [ALPHA] Started. Win logic initialized.");
} else { clearInterval(window.godbot_loop); window.godbot_loop = null; alert("GodBot Stopped."); }`,

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

    // --- 2. 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; }
        #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; border-color: #00ff00; }
        .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);

    // --- 3. LOGIC & UI ---
    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:#00ff00">PRO</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">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')">🚀 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.0</span><button class="tx-btn" onclick="tx_load('GodBot')">LOAD</button></div>
                            <div class="script-item"><span>Ship Radar</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: #555;">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) {
                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 for GodBot features.");
        };

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

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

})();