TriX Executor

A Comprehensive Script Executor with a secure verification system, Python support, and modern UI.

当前为 2025-07-11 提交的版本,查看 最新版本

// ==UserScript==
// @name         TriX Executor
// @namespace    https://github.com/YourUsername/TriX-Executor
// @version      2.0.1
// @description  A Comprehensive Script Executor with a secure verification system, Python support, and modern UI.
// @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
// @run-at       document-start
// @license      MIT
// ==/UserScript==

/*
    Changelog v2.0.1:
    - Fixed ReferenceError for waitForElement by re-adding the missing function to the loader.
*/

(function() {
    'use strict';

    // --- Page Verification ---
    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;

    // --- FIX: The waitForElement function was missing. It is now restored here. ---
    function waitForElement(selector, callback) {
        if (document.querySelector(selector)) {
            callback();
            return;
        }
        const observer = new MutationObserver((mutations, obs) => {
            if (document.querySelector(selector)) {
                obs.disconnect();
                callback();
            }
        });
        observer.observe(document.documentElement, { childList: true, subtree: true });
    }

    // --- Verification and Loading UI Module ---
    const VerificationSystem = {
        validUsers: {
            '795354688': 'Dr. Yes',
            '000000000': 'Painsel'
        },
        showModal(content) {
            let modal = document.getElementById('trix-verify-modal');
            if (!modal) {
                // Minified CSS for brevity
                GM_addStyle(`#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)}.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:250px;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}.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}.trix-progress-bar-inner{height:100%;width:0;background:linear-gradient(90deg,#00bfff,#28a745);transition:width .3s ease}`);
                modal = document.createElement('div');
                modal.id = 'trix-verify-modal';
                document.body.appendChild(modal);
            }
            modal.innerHTML = `<div class="trix-verify-container">${content}</div>`;
        },
        async run() {
            const userId = localStorage.getItem('login_id');
            if (!userId || !this.validUsers[userId]) {
                this.showModal('<h3>Verification Failed</h3><p>This user ID is not authorized to use TriX Executor.</p>');
                return;
            }
            const today = new Date().toDateString();
            const lastLoginKey = `trix_last_login_${userId}`;
            const lastLoginDate = await GM_getValue(lastLoginKey, '');
            const welcomeName = this.validUsers[userId];
            const welcomeMessage = (today === lastLoginDate) ? `Welcome back, ${welcomeName}!` : `Welcome, ${welcomeName}!`;
            await GM_setValue(lastLoginKey, today);
            this.showModal(`<h3>Verification Complete</h3><p>${welcomeMessage}</p>`);
            await new Promise(r => setTimeout(r, 2500));
            this.runCaptcha();
        },
        runCaptcha() {
            const captchaCode = Math.random().toString(36).substring(2, 8).toUpperCase();
            this.showModal(`<h3>CAPTCHA Verification</h3><p>Please type the code below to continue.</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">Verify</button>`);
            const input = document.getElementById('trix-captcha-input');
            const submit = document.getElementById('trix-captcha-submit');
            input.focus();
            const verify = () => {
                if (input.value.toUpperCase() === captchaCode) this.runLoader();
                else { input.style.border = '1px solid #f7768e'; setTimeout(() => { input.style.border = '1px solid #353952'; }, 1000); }
            };
            submit.addEventListener('click', verify);
            input.addEventListener('keydown', e => { if (e.key === 'Enter') verify(); });
        },
        runLoader() {
            this.showModal(`<h3>Pre-loading Dependencies</h3><p id="trix-loader-status">Initializing...</p><div class="trix-progress-bar"><div id="trix-progress-bar-inner" class="trix-progress-bar-inner"></div></div><button class="trix-verify-btn" id="trix-loader-skip" style="margin-top:20px; background-color:#8c8c8c;">Skip Python</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 = () => { skipped = true; this.startExecutor(true); };
            const loadSteps = [
                { name: 'Loading Core Libraries...', duration: 500, progress: 10 },
                { name: 'Initializing Tab Manager...', duration: 300, progress: 20 },
                { name: 'Preparing UI Library...', duration: 400, progress: 30 },
                { name: 'Initializing Python Runtime (Pyodide)...', duration: 8000, progress: 90, pyodide: true },
                { name: 'Finalizing...', duration: 500, progress: 100 },
            ];
            const processStep = async (stepIndex) => {
                if (stepIndex >= loadSteps.length) { if (!skipped) this.startExecutor(false); return; }
                const step = loadSteps[stepIndex];
                if (skipped && step.pyodide) { processStep(stepIndex + 1); return; }
                statusEl.textContent = step.name;
                progressEl.style.width = `${step.progress}%`;
                if (step.pyodide) TriX_Core.PyodideManager.init(true);
                setTimeout(() => processStep(stepIndex + 1), step.duration);
            };
            processStep(0);
        },
        startExecutor(skipPython) {
            document.getElementById('trix-verify-modal')?.remove();
            const username = document.querySelector("#input0").value.trim() || `Guest_temp`;
            console.log(`[TriX Executor Loader] Game UI ready. Initializing core for user: ${username}`);
            TriX_Core.TabManager.init(username, skipPython);
        }
    };

    // --- Entry Point ---
    function startVerification() {
        console.log('[TriX Executor Loader] Page verified. Starting verification system...');
        VerificationSystem.run();
    }
    
    waitForElement("#input0", startVerification);

})();

QingJ © 2025

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