CW Game Time

Показывает время и месяц

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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         CW Game Time
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Показывает время и месяц
// @author       Why? Ева
// @match        https://playtest.cw-game.ru/play
// @icon         https://www.google.com/s2/favicons?sz=64&domain=cw-game.ru
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    function findPlace() {
        const targetDiv = document.querySelector(".css-1byqyzy");
        const dataRect = document.createElement('div');
        const timeRect = document.createElement('div');
        timeRect.id = 'timetime';
        dataRect.id = 'datadata';
        timeRect.style.cssText = "width: 52px; height: 30px; border-radius: 30px; margin-left: 7.99px; display: inline-block; background: rgba(10, 10, 20, 0.63); font-family: 'Neucha', Arial, sans-serif; color: #ffffff; text-align: center; line-height: 30px; font-size: 17px;"
        dataRect.style.cssText = "width: 52px; height: 30px; border-radius: 30px; margin-left: 7.99px; display: inline-block; background: rgba(10, 10, 20, 0.63); font-family: 'Neucha', Arial, sans-serif; color: #ffffff; text-align: center; line-height: 30px; font-size: 17px;"
        targetDiv.parentNode.insertBefore(timeRect, targetDiv.nextSibling);
        timeRect.parentNode.insertBefore(dataRect, timeRect.nextSibling);
    };

    function setTime() {
        const timeRect = document.getElementById('timetime');
        if (!timeRect) return;
        const game = (typeof unsafeWindow !== 'undefined' ? unsafeWindow.CWGPlayground : window.CWGPlayground);
        const virtualDate = game?.getVirtualTime?.().virtualDate || game?.virtualTime?.virtualDate;
        if (!virtualDate || virtualDate.hour === undefined || virtualDate.minute === undefined) {
            timeRect.textContent = "--:--";
            return;
        }
        const hour = String(virtualDate.hour).padStart(2, '0');
        const minute = String(virtualDate.minute).padStart(2, '0');
        timeRect.textContent = `${hour}:${minute}`;
    }

    function setData() {
        const dataRect = document.getElementById('datadata');
        if (!dataRect) return;
        const game = (typeof unsafeWindow !== 'undefined' ? unsafeWindow.CWGPlayground : window.CWGPlayground);
        const virtualDate = game?.getVirtualTime?.().virtualDate || game?.virtualTime?.virtualDate;
        if (!virtualDate || virtualDate.moon === undefined || virtualDate.date === undefined) {
            dataRect.textContent = "--:--";
            return;
        }
        let color = '#ffffff';
        const month = String(virtualDate.moon + 1).padStart(2, '0');
        if ((1 <= month && month <= 2) || month == 12){
            color = '#7ad5ff';
        } else if (3 <= month && month <= 5){
            color = '#c8ffa8';
        } else if (6 <= month && month <= 8){
            color = '#a9ff7a';
        } else if (9 <= month && month <= 11){
            color = '#ff997a';
        }
        const day = String(virtualDate.date + 1).padStart(2, '0');
        dataRect.textContent = `${day}.${month}`;
        dataRect.style.color = color;
    }

    const checkInterval = setInterval(() => {
        if (document.querySelector(".css-1byqyzy")){
            clearInterval(checkInterval);
            findPlace();
            setTime();
            setData();
            setInterval(setTime, 2000);
        }
    }, 1000);
})();