CubeRealm - Simple Join Command

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

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