CubeRealm - Session Timer

Short session timer with reset via chat "0"

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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 = "";
            }
        }
    });
})();