Greasy Fork

Greasy Fork is available in English.

Arras Auto Respawn (Presses Enter on strokeText)

chatgpt script

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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);
    };

})();