TriX Executor

A comprehensive script executor for Territorial.io, created with AI Studio.

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

// ==UserScript==
// @name         TriX Executor
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @description  A comprehensive script executor for Territorial.io, created with AI Studio.
// @author       Your Name / AI Studio Generated
// @match        https://territorial.io/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // --- Core Executor Logic Function ---
    // This function will contain the main code that Google AI Studio generates for you.
    // It will be called when the webpage is ready.
    function runTriXExecutor() {
        console.log('TriX Executor: Attempting to load and inject components...');

        // Check if the executor UI already exists to prevent duplicate injections
        if (document.getElementById('trix-executor-root')) {
            console.log('TriX Executor: Already injected. Skipping.');
            return;
        }

        // =========================================================================
        // PASTE THE JAVASCRIPT CODE GENERATED BY GOOGLE AI STUDIO BELOW THIS LINE
        // =========================================================================

        // --- Example of a basic UI component (you can replace this with AI-generated UI) ---
        const executorDiv = document.createElement('div');
        executorDiv.id = 'trix-executor-root';
        executorDiv.style.position = 'fixed';
        executorDiv.style.top = '10px';
        executorDiv.style.right = '10px';
        executorDiv.style.background = 'rgba(0,0,0,0.8)';
        executorDiv.style.color = 'white';
        executorDiv.style.padding = '15px';
        executorDiv.style.borderRadius = '8px';
        executorDiv.style.border = '1px solid #333';
        executorDiv.style.boxShadow = '0 4px 8px rgba(0,0,0,0.2)';
        executorDiv.style.zIndex = '99999'; // Ensure it's on top of game elements

        // Placeholder for the logo (if you want to include it dynamically)
        const logoImg = document.createElement('img');
        logoImg.src = 'https://i.postimg.cc/0NkRZxDm/image.png';
        logoImg.style.width = '50px';
        logoImg.style.height = '50px';
        logoImg.style.display = 'block';
        logoImg.style.margin = '0 auto 10px';
        executorDiv.appendChild(logoImg);

        const title = document.createElement('h3');
        title.textContent = 'TriX Executor';
        title.style.margin = '0 0 10px 0';
        title.style.textAlign = 'center';
        executorDiv.appendChild(title);

        const statusText = document.createElement('p');
        statusText.id = 'trix-status';
        statusText.textContent = 'Status: Initializing...';
        statusText.style.fontSize = '0.9em';
        executorDiv.appendChild(statusText);

        // Add a simple button to test functionality
        const testButton = document.createElement('button');
        testButton.textContent = 'Test Executor';
        testButton.style.marginTop = '10px';
        testButton.style.width = '100%';
        testButton.style.padding = '8px';
        testButton.style.background = '#4CAF50';
        testButton.style.color = 'white';
        testButton.style.border = 'none';
        testButton.style.borderRadius = '4px';
        testButton.style.cursor = 'pointer';
        testButton.onclick = () => {
            alert('TriX Executor Test Successful!');
            statusText.textContent = 'Status: Ready!';
        };
        executorDiv.appendChild(testButton);

        // Append to the document body
        document.body.appendChild(executorDiv);

        console.log('TriX Executor: UI injected successfully.');

        // =========================================================================
        // PASTE THE JAVASCRIPT CODE GENERATED BY GOOGLE AI STUDIO ABOVE THIS LINE
        // This is where your AI-generated script logic for multi-tabbing,
        // automation, etc., would go.
        // =========================================================================
    }


    // --- Timing Mechanism ---
    // Use a MutationObserver to wait for the page to be stable or specific elements to appear.
    // This is generally the most robust method for dynamic single-page applications like Territorial.io.

    const targetNode = document.body; // Observe changes in the body
    const config = { childList: true, subtree: true }; // Watch for added/removed children anywhere in the DOM

    const observer = new MutationObserver(function(mutationsList, observer) {
        // Look for signs that the game is fully loaded.
        // A good sign might be the presence of the game canvas or a specific game UI element.
        // For example, if the game uses a canvas with a known ID, you can wait for that.
        const gameCanvas = document.querySelector('canvas'); // Or a more specific selector like '#gameCanvasID'

        if (gameCanvas && gameCanvas.offsetParent !== null) { // Check if canvas exists and is visible
            console.log('TriX Executor: Game canvas detected. Attempting to run executor logic.');
            runTriXExecutor(); // Execute your main logic
            observer.disconnect(); // Disconnect observer once executor is loaded to save resources
        } else {
            // As a fallback, try to inject if a certain amount of time passes or
            // if the body seems relatively stable.
            // This part might need fine-tuning based on how territorial.io loads.
            if (!document.getElementById('trix-executor-root')) {
                 // You might also add a small timeout here if the canvas isn't present
                 // but you still want to try injecting after a short delay.
                 // setTimeout(runTriXExecutor, 500); // Only as a secondary fallback
            }
        }
    });

    // Start observing the target node for configured mutations
    observer.observe(targetNode, config);

    // Also try to run it on DOMContentLoaded as a first attempt
    // For simpler pages, this might be enough, but for Territorial.io, MutationObserver is safer.
    document.addEventListener('DOMContentLoaded', function() {
        console.log('TriX Executor: DOMContentLoaded fired. Trying initial injection.');
        runTriXExecutor();
    });

})();

QingJ © 2025

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