CubeRealm - Session Timer

Short session timer with reset via chat "0"

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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