CubeRealm - Session Timer

Short session timer with reset via chat "0"

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

Advertisement:

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

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