CubeRealm - Simple Join Command

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

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==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 = "";
        }
    });
})();