Official TriX Proxy Bot Script

A bot script for territorial.io with a modern UI to simulate typing usernames and clan tags on proxy sites. | Supported Proxies: CroxyProxy

Ekde 2025/09/17. Vidu La ĝisdata versio.

// ==UserScript==
// @name         Official TriX Proxy Bot Script
// @version      0.1.1
// @description  A bot script for territorial.io with a modern UI to simulate typing usernames and clan tags on proxy sites. | Supported Proxies: CroxyProxy
// @author       painsel
// @license      MIT
// @homepageURL  https://greasyfork.org/en/scripts/549132-trix-executor-beta-for-territorial-io
// @match        *://*/*?__cpo=*
// @grant        GM_addStyle
// @namespace    http://tampermonkey.net/
// ==/UserScript==

(function() {
    'use strict';

    // --- 1. Conditional Execution Check for Proxy Sites ---
    const urlParams = new URLSearchParams(window.location.search);
    let isTerritorialProxy = false;

    if (urlParams.has('__cpo')) {
        try {
            const decodedUrl = atob(urlParams.get('__cpo'));
            if (decodedUrl.includes('territorial.io')) {
                isTerritorialProxy = true;
            }
        } catch (e) {
            console.error('[TriX Bot] Invalid __cpo parameter:', e);
        }
    }

    if (!isTerritorialProxy) {
        console.log('[TriX Bot] Not a territorial.io proxy page. Script will not run.');
        return;
    }


    // --- 2. Constants and AI Names ---
    const STORAGE_KEY = 'd122';
    // Expanded list of names for the AI to generate
    const AI_NAMES = [
        // Original
        "Apex", "Vortex", "Shadow", "Nova", "Cipher", "Blaze", "Reaper", "Phantom",
        "Genesis", "Specter", "Warden", "Rogue", "Titan", "Fury", "Serpent", "Oracle",
        "Zenith", "Pulsar", "Jester", "Mirage", "Nomad", "Havoc", "Crux", "Wraith",
        // New Additions
        "Glitch", "Vector", "Flux", "Byte", "Pixel", "Matrix", "Kernel", "Grid",
        "Node", "Syntax", "Griffin", "Wyvern", "Goliath", "Leviathan", "Hydra", "Phoenix",
        "Golem", "Paladin", "Warlock", "Rune", "Storm", "Quake", "Inferno", "Frost",
        "Cyclone", "Meteor", "Comet", "Abyss", "Ember", "Tempest", "Striker", "Raider",
        "Vanguard", "Sentinel", "Commando", "Juggernaut", "Marshal", "Legion", "Phalanx", "Blitz",
        "Saber", "Echo", "Impulse", "Catalyst", "Paradox", "Rift", "Karma", "Legacy",
        "Valor", "Creed", "Requiem", "Solstice", "Equinox", "Infinity", "Axiom", "Enigma",
        "Viper", "Cobra", "Hawk", "Falcon", "Tiger", "Wolf", "Panther", "Jackal",
        "Goliath", "Javelin", "Overload", "Torrent", "Cascade", "Helix", "Ion", "Ronin",
        "Monarch", "Zealot", "Herald", "Jinx", "Quasar"
    ];


    // --- 3. UI Styling (VS Code Theme) ---
    const trixCSS = `
        :root {
            --trix-bg: #1e1e1e;
            --trix-bg-light: #252526;
            --trix-header-bg: #333333;
            --trix-border: #3c3c3c;
            --trix-text: #d4d4d4;
            --trix-text-secondary: #cccccc;
            --trix-blue-accent: #007acc;
            --trix-button-bg: #0e639c;
            --trix-button-hover-bg: #1177bb;
            --trix-input-bg: #3c3c3c;
        }

        #trix-container {
            position: fixed;
            top: 20px;
            left: 20px;
            width: 280px;
            background-color: var(--trix-bg-light);
            border: 1px solid var(--trix-border);
            border-radius: 6px;
            color: var(--trix-text);
            font-family: 'Consolas', 'Menlo', 'Courier New', monospace;
            font-size: 14px;
            z-index: 99999;
            box-shadow: 0 5px 20px rgba(0,0,0,0.5);
            user-select: none;
            overflow: hidden;
        }

        #trix-header {
            background-color: var(--trix-header-bg);
            padding: 8px 12px;
            cursor: move;
            font-weight: bold;
            border-bottom: 1px solid var(--trix-border);
        }

        #trix-header a {
            color: var(--trix-blue-accent);
            text-decoration: none;
        }
         #trix-header a:hover {
            text-decoration: underline;
        }

        #trix-body {
            padding: 15px;
            display: flex;
            flex-direction: column;
            gap: 15px;
        }

        .trix-input-group {
            display: flex;
            flex-direction: column;
            gap: 5px;
        }

        .trix-input-group label {
            font-size: 13px;
            color: var(--trix-text-secondary);
        }

        .trix-input-group input[type="text"],
        .trix-input-group select {
            background-color: var(--trix-input-bg);
            border: 1px solid var(--trix-border);
            color: var(--trix-text);
            padding: 8px;
            border-radius: 4px;
            font-family: inherit;
            outline: none;
            transition: border-color 0.2s, background-color 0.2s;
        }

        .trix-input-group input[type="text"]:focus,
        .trix-input-group select:focus {
            border-color: var(--trix-blue-accent);
        }

        .trix-input-group input[type="text"]:disabled {
            background-color: #2a2a2a;
            color: #888;
            cursor: not-allowed;
        }

        #trix-start-btn {
            background-color: var(--trix-button-bg);
            color: white;
            border: none;
            padding: 10px;
            border-radius: 4px;
            font-family: inherit;
            font-size: 14px;
            font-weight: bold;
            cursor: pointer;
            transition: background-color 0.2s;
        }

        #trix-start-btn:hover {
            background-color: var(--trix-button-hover-bg);
        }

        #trix-start-btn:disabled {
            background-color: #5a5a5a;
            cursor: not-allowed;
        }

        .trix-radio-group {
            display: flex;
            gap: 15px;
        }
        .trix-radio-group label {
            display: flex;
            align-items: center;
            gap: 5px;
            cursor: pointer;
        }
    `;

    // --- 4. UI HTML Structure ---
    const trixHTML = `
        <div id="trix-container">
            <div id="trix-header">
                Official <a href="https://greasyfork.org/en/scripts/549132-trix-executor-beta-for-territorial-io" target="_blank">TriX</a> Proxy Bot
            </div>
            <div id="trix-body">
                <div class="trix-input-group">
                    <label for="trix-clan-tag">Clan Tag (Customizable in AI mode)</label>
                    <input type="text" id="trix-clan-tag" placeholder="e.g., TriX">
                </div>
                <div class="trix-input-group">
                    <label for="trix-username">Username</label>
                    <input type="text" id="trix-username" placeholder="Enter your name">
                </div>
                <div class="trix-input-group">
                    <label>Mode</label>
                    <div class="trix-radio-group">
                        <label>
                            <input type="radio" name="trix-typing-style" value="custom" checked> Custom
                        </label>
                        <label>
                            <input type="radio" name="trix-typing-style" value="ai"> AI
                        </label>
                    </div>
                </div>
                <button id="trix-start-btn">Begin Typing Simulation</button>
            </div>
        </div>
    `;

    // --- 5. Core Logic ---
    function simulateTyping(element, text, onComplete) {
        let i = 0;
        element.value = '';
        element.focus();
        function typeCharacter() {
            if (i < text.length) {
                element.value += text.charAt(i);
                element.dispatchEvent(new Event('input', { bubbles: true }));
                i++;
                const delay = Math.random() * 150 + 50;
                setTimeout(typeCharacter, delay);
            } else {
                element.blur();
                if (onComplete) onComplete();
            }
        }
        typeCharacter();
    }

    function saveSettings() {
        const clanTag = document.getElementById('trix-clan-tag').value;
        const username = document.getElementById('trix-username').value;
        localStorage.setItem(STORAGE_KEY, JSON.stringify({ clanTag, username }));
    }

    function loadSettings() {
        const settings = localStorage.getItem(STORAGE_KEY);
        if (settings) {
            try {
                const { clanTag, username } = JSON.parse(settings);
                document.getElementById('trix-clan-tag').value = clanTag || '';
                document.getElementById('trix-username').value = username || '';
            } catch (e) { console.error('[TriX Bot] Failed to load settings:', e); }
        }
    }

    function initializeUI() {
        if (document.getElementById('trix-container')) return;

        GM_addStyle(trixCSS);
        document.body.insertAdjacentHTML('beforeend', trixHTML);

        const container = document.getElementById('trix-container');
        const header = document.getElementById('trix-header');
        const clanTagInput = document.getElementById('trix-clan-tag');
        const usernameInput = document.getElementById('trix-username');
        const startBtn = document.getElementById('trix-start-btn');
        const radioButtons = document.querySelectorAll('input[name="trix-typing-style"]');

        const toggleUsernameInput = () => {
            const selectedMode = document.querySelector('input[name="trix-typing-style"]:checked').value;
            usernameInput.disabled = (selectedMode === 'ai');
            usernameInput.placeholder = (selectedMode === 'ai') ? "AI will generate a name" : "Enter your name";
        };

        radioButtons.forEach(radio => radio.addEventListener('change', toggleUsernameInput));
        loadSettings();
        clanTagInput.addEventListener('input', saveSettings);
        usernameInput.addEventListener('input', saveSettings);
        toggleUsernameInput();

        startBtn.addEventListener('click', () => {
            const clanTag = clanTagInput.value.trim();
            const typingStyle = document.querySelector('input[name="trix-typing-style"]:checked').value;
            const nameInput = document.querySelector('#input0');
            let fullName, username;

            if (!nameInput) { alert('[TriX Bot] Could not find the game\'s name input field.'); return; }

            if (typingStyle === 'ai') {
                username = AI_NAMES[Math.floor(Math.random() * AI_NAMES.length)];
                if (!clanTag) {
                    fullName = username;
                } else {
                    const formats = ['standard', 'possessive', 'lowerTag', 'tagAfter'];
                    const chosenFormat = formats[Math.floor(Math.random() * formats.length)];
                    switch (chosenFormat) {
                        case 'standard': fullName = `[${clanTag}] ${username}`; break;
                        case 'possessive': fullName = `[${clanTag}]'s ${username}`; break;
                        case 'lowerTag': fullName = `[${clanTag.toLowerCase()}] ${username}`; break;
                        case 'tagAfter': fullName = `${username} [${clanTag.toLowerCase()}]`; break;
                        default: fullName = `[${clanTag}] ${username}`; break;
                    }
                }
            } else {
                username = usernameInput.value.trim();
                if (!username) { alert('[TriX Bot] Please enter a username for Custom mode.'); return; }
                fullName = clanTag ? `[${clanTag}] ${username}` : username;
            }

            startBtn.disabled = true;
            startBtn.textContent = 'Typing...';
            simulateTyping(nameInput, fullName, () => {
                startBtn.disabled = false;
                startBtn.textContent = 'Begin Typing Simulation';
            });
        });

        let isDragging = false, offsetX, offsetY;
        header.addEventListener('mousedown', (e) => {
            isDragging = true;
            offsetX = e.clientX - container.offsetLeft;
            offsetY = e.clientY - container.offsetTop;
            document.addEventListener('mousemove', onMouseMove);
            document.addEventListener('mouseup', onMouseUp);
        });
        function onMouseMove(e) { if (isDragging) { container.style.left = `${e.clientX - offsetX}px`; container.style.top = `${e.clientY - offsetY}px`; } }
        function onMouseUp() { isDragging = false; document.removeEventListener('mousemove', onMouseMove); document.removeEventListener('mouseup', onMouseUp); }
    }

    // --- 6. Script Execution Logic ---
    function findMultiplayerButton() {
        for (const btn of document.querySelectorAll('button')) { if (btn.innerText && btn.innerText.includes('Multiplayer')) return btn; }
        return null;
    }

    function waitForGameUI(callback) {
        if (findMultiplayerButton()) { callback(); return; }
        const observer = new MutationObserver((mutations, obs) => {
            if (findMultiplayerButton()) { obs.disconnect(); callback(); }
        });
        observer.observe(document.documentElement, { childList: true, subtree: true });
    }

    waitForGameUI(initializeUI);

    /*
    The MIT License (MIT)
    Copyright (c) 2024 painsel
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
    */
})();