Arras Auto Respawn (Presses Enter on strokeText)

chatgpt script

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Arras Auto Respawn (Presses Enter on strokeText)
// @namespace    autorespawnEnterStroke
// @description  chatgpt script
// @version      1.0
// @match        *://arras.io/*
// @match        *://arras.glitch.me/*
// @match        *://*arras*/*
// @grant        none
// @license      dont steal
// ==/UserScript==

(function() {
    'use strict';

    const origStrokeText = CanvasRenderingContext2D.prototype.strokeText;

    // Function to simulate the Enter key
    function pressEnter() {
        const ev1 = new KeyboardEvent("keydown", {
            key: "Enter",
            code: "Enter",
            keyCode: 13,
            which: 13,
            bubbles: true
        });
        const ev2 = new KeyboardEvent("keyup", {
            key: "Enter",
            code: "Enter",
            keyCode: 13,
            which: 13,
            bubbles: true
        });

        document.dispatchEvent(ev1);
        document.dispatchEvent(ev2);

        console.log("[AutoRespawn] Simulated ENTER key press.");
    }

    // Patch strokeText
    CanvasRenderingContext2D.prototype.strokeText = function(text, ...rest) {

        if (typeof text === "string") {
            const lower = text.trim().toLowerCase();

            // Detect the Respawn button text being drawn
            if (lower === "respawn") {
                console.log("[AutoRespawn] Respawn text detected — pressing Enter.");

                // Press Enter immediately and again shortly after
                pressEnter();
                setTimeout(pressEnter, 50);
                setTimeout(pressEnter, 150);
            }
        }

        return origStrokeText.call(this, text, ...rest);
    };

})();