System Clock and Calendar

Display the system clock and calendar at the bottom right corner of the site in Chrome browser.

目前為 2023-09-12 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         System Clock and Calendar
// @description  Display the system clock and calendar at the bottom right corner of the site in Chrome browser.
// @namespace    https://github.com/Rainman69/
// @version      1.0
// @author       https://t.me/TheErfon
// @match        *://*/*
// @grant        none
// @license      CC BY-NC-ND 4.0
// @licenseURL   https://github.com/Rainman69/live-Time-date-for-browser/blob/main/LICENSE
// ==/UserScript==

(function() {
    'use strict';

    var systemDateDiv = document.createElement('div');
    systemDateDiv.style.position = 'fixed';
    systemDateDiv.style.bottom = '0';
    systemDateDiv.style.right = '0';
    systemDateDiv.style.width = '40%';
    systemDateDiv.style.padding = '5px';
    systemDateDiv.style.fontFamily = 'digital-7 (mono)';
    systemDateDiv.style.fontSize = '12px';
    systemDateDiv.style.textAlign = 'center';
    systemDateDiv.style.zIndex = '9999';
    systemDateDiv.style.textShadow = '0px -2px 4px rgba(0, 0, 0, 0.3)';
    systemDateDiv.style.transition = 'opacity 0.5s ease-in-out';

    function updateTime() {
        var currentDate = new Date();
        var options = { year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric', hour12: true };
        var formattedDate = currentDate.toLocaleString('en-US', options);

        systemDateDiv.textContent = formattedDate;
    }

    function handleScroll() {
        if (isScrolling) {
            clearTimeout(scrollingTimer);
        } else {
            systemDateDiv.style.opacity = '0';
        }

        isScrolling = true;

        scrollingTimer = setTimeout(function() {
            isScrolling = false;
            systemDateDiv.style.opacity = '1';
        }, 1000);
    }

    var isScrolling = false;
    var scrollingTimer;

    updateTime();

    window.addEventListener('scroll', handleScroll);

    document.body.appendChild(systemDateDiv);

    // Update the time every second
    setInterval(updateTime, 1000);
})();