Clock figuccio 12-24

clock ore ampm 24h al passaggio mouse

// ==UserScript==
// @name           Clock figuccio 12-24
// @description    clock ore ampm 24h al passaggio mouse
// @version        0.3
// @match          *://*/*
// @noframes
// @author         figuccio
// @grant          GM_setValue
// @grant          GM_getValue
// @grant          GM_registerMenuCommand
// @license        MIT
// @icon           data:image/gif;base64,R0lGODlhEAAQAKECABEREe7u7v///////yH5BAEKAAIALAAAAAAQABAAAAIplI+py30Bo5wB2IvzrXDvaoFcCIBeeXaeSY4tibqxSWt2RuWRw/e+UQAAOw==
// @namespace https://greasyfork.org/users/237458
// ==/UserScript==
    //12h
 function getCurrentTime() {
        const now = new Date();
        let hours = now.getHours();
        const minutes = now.getMinutes();
        const seconds = now.getSeconds();
        const milliseconds = now.getMilliseconds();
        const ampm = hours >= 12 ? 'PM' : 'AM';

        hours = hours % 12;
        hours = hours ? hours : 12; // 12-hour clock

        const timeString = hours.toString().padStart(2, '0') + ':' +
                           minutes.toString().padStart(2, '0') + ':' +
                           seconds.toString().padStart(2, '0') + ':' +
                           milliseconds.toString().padStart(3, '0') + ' ' + ampm;

        return timeString;
    }

    function displayTime() {
        const timeContainer = document.createElement('div');
        timeContainer.id='test';
        timeContainer.style. display='none!important';
        timeContainer.style.position = 'fixed';
        timeContainer.style.top = '0px';
        timeContainer.style.left = '0px';
        timeContainer.style.background = 'black';
        timeContainer.style.padding = '5px';
        timeContainer.style.border = '2px solid gold';
        timeContainer.style.borderRadius = '5px';
        timeContainer.style.fontFamily = 'Arial, sans-serif';
        timeContainer.style.fontSize = '14px';
        timeContainer.style.color = 'lime';
        timeContainer.style.zIndex = '9999';
        document.body.appendChild(timeContainer);

        setInterval(function() {
            timeContainer.textContent = getCurrentTime();
        }, 100); // Update every 100 milliseconds
    }

    displayTime();

////////////////////////
function updateClock() {
var time = new Date().toLocaleTimeString('it', { hour12: false, });
var d = new Date();
var ms = d.getMilliseconds()
node.innerHTML =time+":" +ms;
}
let node = document.createElement('div');
////////////
node.id = "c";
node.title = '24h';
node.setAttribute("style","display:none;cursor:;padding:4px;background:black;color:lime;top:0;font-family:sans-serif;font-size:14px;position:fixed;text-align:center;z-index:999999;border-radius:10px;border:2px solid yellow;");
document.body.appendChild(node);
setInterval(() => updateClock(), 70);
///////////////////////////////////
 function Function14() { if (node.style.display === 'none') { node.style.display = 'block'; document.getElementById("test").style.display = 'none'; }
  else {node.style.display = 'none';document.getElementById("test").style.display = 'block';}
}
GM_registerMenuCommand("nascondi/mostra 12/24h",Function14);
node.addEventListener('mouseout', Function14);//passaggio del mouse
document.getElementById("test").addEventListener('mouseover',Function14 );//toglie il mouse
//////////////////////////////