mini clock 2025figuccio

clock 2025 dragabile

当前为 2025-04-26 提交的版本,查看 最新版本

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

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

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

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

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

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         mini clock 2025figuccio
// @namespace    https://greasyfork.org/users/237458
// @description  clock 2025 dragabile
// @version      2.3
// @match        *://*/*
// @noframes
// @grant        GM_addStyle
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_registerMenuCommand
// @icon         data:image/gif;base64,R0lGODlhEAAQAKECABEREe7u7v///////yH5BAEKAAIALAAAAAAQABAAAAIplI+py30Bo5wB2IvzrXDvaoFcCIBeeXaeSY4tibqxSWt2RuWRw/e+UQAAOw==
// @require      http://code.jquery.com/jquery-latest.js
// @require      https://code.jquery.com/ui/1.13.2/jquery-ui.js
// @license      MIT
// ==/UserScript==
(function() {
    'use strict';
    var $ = window.jQuery;

    function savePosition(left, top) {
        GM_setValue('clockPosition', JSON.stringify({ left, top }));
    }

    function loadPosition() {
        let position = GM_getValue('clockPosition');
        return position ? JSON.parse(position) : { left: '900px', top: '0px' };
    }

    var clock = $('<div>', {
        css: {
            position: 'fixed',
            fontSize: '16px',
            background: '#181818',
            cursor: 'pointer',
            padding: '4px',
            color: 'red',
            border: '2px solid green',
            borderRadius: '5px',
            zIndex: '999999',
            textAlign: 'center'
        }
    }).text('00:00:00:000').appendTo(document.body);

    function updateClock() {
        var now = new Date();
        clock.text(`${now.getHours().toString().padStart(2, '0')}:${now.getMinutes().toString().padStart(2, '0')}:${now.getSeconds().toString().padStart(2, '0')}:${now.getMilliseconds().toString().padStart(3, '0')}`);
    }

    setInterval(updateClock, 90);

    clock.hover(function() {
        let currentDate = new Date();
        clock.attr('title', currentDate.toLocaleDateString('it', { day: '2-digit', month: 'long', weekday: 'long', year: 'numeric' }));
    });

    $(document).ready(function() {
        clock.draggable({
            containment: 'window',
            stop: function(event, ui) {
                savePosition(ui.position.left, ui.position.top);
            }
        });

        let savedPosition = loadPosition();
        clock.css({ left: savedPosition.left, top: savedPosition.top });

        window.addEventListener('beforeunload', function() {
            let currentPosition = clock.position();
            savePosition(currentPosition.left, currentPosition.top);
        });
    });

    GM_registerMenuCommand('Mostra/Nascondi Orologio', function() {
        clock.toggle();
    });

})();