CubeRealm - Simple Join Command

Ajoute une commande /join <mode> <region> pour rejoindre un serveur CubeRealm

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

You will need to install an extension such as Tampermonkey to install this script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         CubeRealm - Simple Join Command
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Ajoute une commande /join <mode> <region> pour rejoindre un serveur CubeRealm
// @match        https://cuberealm.io/*
// @match        https://www.cuberealm.io/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Fonction de redirection
    function joinServer(mode, region) {
        const url = `https://cuberealm.io/?mode=${encodeURIComponent(mode)}&region=${encodeURIComponent(region)}`;
        window.location.href = url;
    }

    // Détection du chat (nouveau système CubeRealm)
    document.addEventListener("keydown", function(e) {
        if (e.key !== "Enter") return;

        const input = document.querySelector("input[maxlength='100'], textarea");
        if (!input) return;

        const msg = input.value.trim();

        if (msg.startsWith("/join ")) {
            const parts = msg.split(" ");
            if (parts.length === 3) {
                const mode = parts[1];
                const region = parts[2];
                joinServer(mode, region);
            }
            input.value = "";
        }
    });
})();