Greasy Fork is available in English.

Clock figuccio 12-24

clock ore ampm 24h doppio click per cambiare

// ==UserScript==
// @name        Clock figuccio 12-24
// @description clock ore ampm 24h doppio click per cambiare
// @version     0.4
// @include     *
// @noframes
// @author      figuccio
// @grant       GM_setValue
// @grant       GM_getValue
// @grant       GM_registerMenuCommand
// @icon        data:image/gif;base64,R0lGODlhEAAQAKECABEREe7u7v///////yH5BAEKAAIALAAAAAAQABAAAAIplI+py30Bo5wB2IvzrXDvaoFcCIBeeXaeSY4tibqxSWt2RuWRw/e+UQAAOw==
// @namespace https://greasyfork.org/users/237458
// ==/UserScript==
/*  true=ampm  false=24h  */
     //24h
function updateClock() {
let time = new Date().toLocaleTimeString('it', { hour12: false, });
let d = new Date();
let ms = d.getMilliseconds()
node.innerHTML =time+":" +ms;
}
let node = document.createElement('div');
////////////
node.id = "c";
node.title = '2 click per time am-pm';
node.setAttribute("style","cursor:move;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);
    //12h
function Clock() {
var time2 = new Date().toLocaleTimeString('en-US', { hour12: true,hour:'2-digit', minute:'2-digit',second:'2-digit', });
node2.innerHTML =time2;
}
let node2 = document.createElement('div');
node.id = "d";
node2.title = '2click per time 24h';
node2.setAttribute("style","display:none!important;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(node2);
setInterval(() => Clock(), 1000);

function Function14() {
  if (node.style.display === 'none') {
    node.style.display = 'block';
       node2.style.display = 'none';
  } else {
    node.style.display = 'none';
      node2.style.display = 'block';
  }
}
GM_registerMenuCommand("12h/24h",Function14);

      //funziona cambia 12-24h al click
node2.addEventListener("dblclick", Function14);
node.addEventListener("dblclick", Function14);
/////////////////////////////////////////////

//node2.style.display = 'none';
//////////////
//Make the DIV element draggagle:
dragElement(document.getElementById("d"));

function dragElement(elmnt) {
  var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
  if (document.getElementById(elmnt.id + "header")) {
    /* if present, the header is where you move the DIV from:*/
    document.getElementById(elmnt.id + "header").onmousedown = dragMouseDown;
  } else {
    /* otherwise, move the DIV from anywhere inside the DIV:*/
    elmnt.onmousedown = dragMouseDown;
  }

  function dragMouseDown(e) {
    e = e || window.event;
    e.preventDefault();
    // get the mouse cursor position at startup:
    pos3 = e.clientX;
    pos4 = e.clientY;
    document.onmouseup = closeDragElement;
    // call a function whenever the cursor moves:
    document.onmousemove = elementDrag;
  }

  function elementDrag(e) {
    e = e || window.event;
    e.preventDefault();
    // calculate the new cursor position:
    pos1 = pos3 - e.clientX;
    pos2 = pos4 - e.clientY;
    pos3 = e.clientX;
    pos4 = e.clientY;
    // set the element's new position:
    elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
    elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
  }

  function closeDragElement() {
    /* stop moving when mouse button is released:*/
    document.onmouseup = null;
    document.onmousemove = null;
  }
}