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.1
// @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
// @require      https://gf.qytechs.cn/scripts/ZZZZZZ-trix-ui-library/code/TriX%20UI%20Library.js
//
// @run-at       document-start
// @license      MIT
// ==/UserScript==

/*
    IMPORTANT: The two @require URLs above are placeholders. You MUST replace
    them with the real URLs you get after publishing your library scripts on Greasy Fork镜像.

    Example of a real URL:
    https://gf.qytechs.cn/scripts/495001-trix-core-library/code/TriX%20Core%20Library.js
*/

(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.
        TriX_Core.TabManager.init(username);
    }

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

})();

QingJ © 2025

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