TriX Executor

A Comprehensive Script Executor for Territorial.io with proxy support, a modern UI, and tab management.

目前為 2025-07-02 提交的版本,檢視 最新版本

// ==UserScript==
// @name         TriX Executor
// @namespace    https://github.com/YourUsername/TriX-Executor
// @version      1.4.0
// @description  A Comprehensive Script Executor for Territorial.io with proxy support, a modern UI, and tab management.
// @author       You
// @match        *://territorial.io/*
// @match        *://www.territorial.io/*
// @match        *://*.*.*.*/*
// @icon         https://i.postimg.cc/0NkRZxDm/image.png
// @grant        GM_addStyle
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_listValues
// @grant        GM_deleteValue
// @grant        GM_addValueChangeListener
// @grant        GM.xmlHttpRequest
// @require      https://gf.qytechs.cn/scripts/XXXXXX-trix-core-library/code/TriX%20Core%20Library.js?version=YYYYYY
// @require      https://gf.qytechs.cn/scripts/ZZZZZZ-trix-ui-library/code/TriX%20UI%20Library.js?version=WWWWWW
// @run-at       document-start
// @license      MIT
// ==/UserScript==

/*
    This is the user-facing loader script. It is lightweight and its only job is to:
    1. Verify it's on the correct page (territorial.io or a proxy).
    2. Wait for the game's UI to load.
    3. Call the main library functions provided by the @require'd scripts.
*/

(function() {
    'use strict';

    // This function runs first to ensure the script only executes on the correct pages.
    function isTerritorialPage() {
        if (window.location.hostname.includes('territorial.io')) return true;
        try {
            const cpoParam = new URLSearchParams(window.location.search).get('__cpo');
            if (cpoParam && atob(cpoParam).includes('territorial.io')) return true;
        } catch (e) { /* ignore */ }
        return false;
    }

    if (!isTerritorialPage()) {
        return; // Halt execution if not the correct page.
    }

    console.log('[TriX Executor Loader] Page verified. Waiting for game UI...');

    // This function waits for a key element to appear in the DOM before executing the callback.
    function waitForElement(selector, callback) {
        if (document.querySelector(selector)) return void callback();
        const observer = new MutationObserver((mutations, obs) => {
            if (document.querySelector(selector)) {
                obs.disconnect();
                callback();
            }
        });
        observer.observe(document.documentElement, { childList: true, subtree: true });
    }

    // This function is the entry point after the page is ready.
    function startExecutor() {
        const GAME_READY_SELECTOR = '#input0';
        const username = document.querySelector(GAME_READY_SELECTOR).value.trim() || `Guest_temp`;
        console.log(`[TriX Executor Loader] Game UI ready. Initializing core for user: ${username}`);

        // The TriX_Core and TriX_UI objects are available globally thanks to @require.
        // We start the core logic, which will then decide if it needs to initialize the UI.
        TriX_Core.TabManager.init(username);
    }

    // --- Entry Point ---
    waitForElement("#input0", startExecutor);

})();

QingJ © 2025

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