mini clock 2025figuccio

clock 2025 dragabile

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         mini clock 2025figuccio
// @namespace    https://greatest.deepsurf.us/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();
    });

})();