CubeRealm - Session Timer

Short session timer with reset via chat "0"

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!)

Advertisement:

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!)

Advertisement:

// ==UserScript==
// @name         CubeRealm - Session Timer
// @match        https://cuberealm.io/*
// @grant        none
// @description  Short session timer with reset via chat "0"

// @version 0.0.1.20260626140700
// @namespace https://greasyfork.org/users/1579200
// ==/UserScript==
(function() {
    let startTime = Date.now();

    // Création de l'affichage
    const timerDiv = document.createElement("div");
    timerDiv.style.position = "absolute";
    timerDiv.style.top = "10px";
    timerDiv.style.left = "10px";
    timerDiv.style.color = "white";
    timerDiv.style.fontSize = "18px";
    timerDiv.style.fontFamily = "Arial";
    timerDiv.style.background = "rgba(0,0,0,0.4)";
    timerDiv.style.padding = "6px 10px";
    timerDiv.style.borderRadius = "6px";
    timerDiv.style.zIndex = "9999";
    timerDiv.innerText = "Temps de jeu : 0:00";
    document.body.appendChild(timerDiv);

    // Mise à jour du timer
    setInterval(() => {
        let elapsed = Math.floor((Date.now() - startTime) / 1000);
        let minutes = Math.floor(elapsed / 60);
        let seconds = elapsed % 60;
        timerDiv.innerText = `Temps de jeu : ${minutes}:${seconds.toString().padStart(2, "0")}`;
    }, 1000);

    // Reset quand tu écris "0" dans le chat
    document.addEventListener("keydown", (e) => {
        if (e.key === "Enter") {
            const chatInput = document.querySelector("input[type='text']");
            if (chatInput && chatInput.value.trim() === "0") {
                startTime = Date.now();
                chatInput.value = "";
            }
        }
    });
})();