TriX Executor

A modular, secure, and extensible script executor for Territorial.io.

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

// ==UserScript==
// @name         TriX Executor
// @namespace    https://github.com/YourUsername/TriX-Executor
// @version      3.1.0 [Minor Fix]
// @description  A modular, secure, and extensible script executor for Territorial.io.
// @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://cdn.jsdelivr.net/npm/[email protected]/dist/html2canvas.min.js
// @require      https://gf.qytechs.cn/scripts/541461-trix-core-library/code/TriX%20Core%20Library.js
// @require      https://gf.qytechs.cn/scripts/541462-trix-ui-library/code/TriX%20UI%20Library.js
// @require      https://gf.qytechs.cn/scripts/542296-trix-addons-library/code/TriX%20Addons%20Library.js
// @run-at       document-start
// @license      MIT
// ==/UserScript==

/*
    TriX Executor - Main Loader v3.1.0
    This script is the entry point. It loads all necessary libraries and
    hands off control to the verification system.

    NOTE: The 'TriX_Verification_Library' has been integrated directly into this
    loader for simplicity and to ensure the verification process always runs
    without depending on an external library fetch.
*/
(function() {
    'use strict';
    function isTerritorialPage(){if(window.location.hostname.includes('territorial.io'))return!0;try{const e=new URLSearchParams(window.location.search).get('__cpo');if(e&&atob(e).includes('territorial.io'))return!0}catch(e){}return!1}
    if(!isTerritorialPage()){return}

    function waitForElement(e,t){if(document.querySelector(e))return void t();const o=new MutationObserver((c,r)=>{document.querySelector(e)&&(r.disconnect(),t())});o.observe(document.documentElement,{childList:!0,subtree:!0})}

    // --- Integrated Verification System ---
    const VerificationSystem = {
        validUsers: { '795354688': 'Dr. Yes', '000000000': 'Painsel' },
        currentUserID: null,

        showModal(content) {
            let modal = document.getElementById('trix-verify-modal');
            if (!modal) {
                GM_addStyle(`@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;700&family=Fira+Code&display=swap');#trix-verify-modal{position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(26,27,38,.9);z-index:2000000;display:flex;align-items:center;justify-content:center;backdrop-filter:blur(5px);font-family:'Poppins',sans-serif}.trix-verify-container{background:#2a2d3d;padding:30px;border-radius:10px;text-align:center;color:#e0e0e0;box-shadow:0 8px 32px rgba(0,0,0,.4);width:400px;}.trix-verify-container h3{margin-top:0;color:#00bfff;}.trix-captcha-code{background:#1e202b;padding:10px 20px;border-radius:5px;font-family:'Fira Code',monospace;font-size:24px;letter-spacing:10px;margin:20px 0;user-select:none;}.trix-verify-input{padding:10px;font-size:16px;width:90%;text-align:center;border-radius:5px;border:1px solid #353952;background:#1e202b;color:#e0e0e0;margin-bottom:20px;}.trix-verify-btn{padding:10px 20px;border:none;border-radius:5px;cursor:pointer;background:#00bfff;color:#fff;font-weight:700;transition:background-color .2s;}.trix-verify-btn:hover{background-color:#00a0d8}.trix-verify-btn:disabled{background:#414868;cursor:not-allowed}.trix-progress-bar{width:100%;background:#1e202b;border-radius:5px;overflow:hidden;height:20px;margin-top:15px;border:1px solid #16161e}.trix-progress-bar-inner{height:100%;width:0;background:linear-gradient(90deg,#00bfff,#28a745);transition:width .3s ease,background-color .3s ease;}`);
                modal = document.createElement('div');
                modal.id = 'trix-verify-modal';
                document.body.appendChild(modal);
            }
            modal.innerHTML = `<div class="trix-verify-container">${content}</div>`;
        },

        run() {
            this.showIdInput();
        },
        
        showIdInput() {
            this.showModal(`<h3>TriX Executor Verification</h3><p>Please enter your authorized User ID.</p><input type="text" class="trix-verify-input" id="trix-id-input" placeholder="Enter User ID"><button class="trix-verify-btn" id="trix-id-submit">Verify ID</button>`);
            const input = document.getElementById('trix-id-input');
            const submit = document.getElementById('trix-id-submit');
            input.focus();
            
            const verifyId = () => {
                const enteredId = input.value.trim();
                if (this.validUsers[enteredId]) {
                    this.currentUserID = enteredId;
                    this.runCaptcha();
                } else {
                    input.style.border = '1px solid #f7768e';
                    input.value = 'Invalid ID';
                    setTimeout(() => { input.style.border = '1px solid #353952'; input.value = ''; }, 1500);
                }
            };
            submit.addEventListener('click', verifyId);
            input.addEventListener('keydown', e => { if (e.key === 'Enter') verifyId(); });
        },

        async runCaptcha() {
            const welcomeName = this.validUsers[this.currentUserID];
            const captchaCode = Math.random().toString(36).substring(2, 8).toUpperCase();
            this.showModal(`<h3>Welcome, ${welcomeName}!</h3><p>Please complete the CAPTCHA below.</p><div class="trix-captcha-code">${captchaCode}</div><input type="text" class="trix-verify-input" id="trix-captcha-input" maxlength="6" autocomplete="off"><button class="trix-verify-btn" id="trix-captcha-submit">Continue</button>`);
            const input = document.getElementById('trix-captcha-input');
            const submit = document.getElementById('trix-captcha-submit');
            input.focus();
            const verifyCaptcha = () => { if (input.value.toUpperCase() === captchaCode) this.runLoader(); else { input.style.border = '1px solid #f7768e'; } };
            submit.addEventListener('click', verifyCaptcha);
            input.addEventListener('keydown', e => { if (e.key === 'Enter') verifyCaptcha(); });
        },

        runLoader() {
            this.showModal(`<h3>Preparing TriX Environment</h3><p id="trix-loader-status" style="height:20px; transition: color .3s;">Initializing...</p><div class="trix-progress-bar"><div id="trix-progress-bar-inner"></div></div><button class="trix-verify-btn" id="trix-loader-skip" style="margin-top:20px; background-color:#8c8c8c;">Skip Pre-load</button>`);
            const statusEl = document.getElementById('trix-loader-status');
            const progressEl = document.getElementById('trix-progress-bar-inner');
            const skipBtn = document.getElementById('trix-loader-skip');
            let skipped = false;
            skipBtn.onclick = () => { if (skipped) return; skipped = true; TriX_Core.PyodideManager.isSkipped = true; this.onVerificationSuccess(); };
            const pyodidePromise = TriX_Core.PyodideManager.init(true, (progress) => { statusEl.textContent = progress.what; if(progress.total) { progressEl.style.width = `${(progress.loaded / progress.total) * 100}%`; } });
            pyodidePromise
                .then(() => { if (!skipped) { statusEl.textContent = "Finalizing..."; progressEl.style.width = '100%'; setTimeout(() => this.onVerificationSuccess(), 500); } })
                .catch(err => { if (!skipped) { statusEl.textContent = "Python failed to load. You can continue without it."; statusEl.style.color = '#f7768e'; progressEl.style.backgroundColor = '#f7768e'; skipBtn.textContent = "Continue without Python"; } });
        },

        onVerificationSuccess() {
            document.getElementById('trix-verify-modal')?.remove();
            const username = document.querySelector("#input0").value.trim() || `Guest_temp`;
            console.log(`[TriX] Verification successful. Initializing core for user: ${username}`);
            TriX_Core.TabManager.init(username);
        }
    };
    
    console.log('[TriX Loader] Page verified. Starting verification system...');
    waitForElement("#input0", () => VerificationSystem.run());
    
})();

QingJ © 2025

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