Clock figuccio

clock ore minuti secondi millesimi data

目前为 2020-06-23 提交的版本。查看 最新版本

// ==UserScript==
// @name        Clock figuccio
// @description clock ore minuti secondi millesimi data
// @version     2.0
// @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://gf.qytechs.cn/users/237458
// ==/UserScript==
/* short long  true=ampm  false=24h lingua en-US ok am pm mezzogiorno 12:00 .lingua it mezzogiorno ampm 0:00  */
var use_date = true;
function updateClock() {
    var period = "",
		fulldate = "",
        date = new Date();
let time = new Date().toLocaleTimeString('en-US', { hour12: false,hour:'2-digit', minute:'2-digit',second:'2-digit',});
let d = new Date();
let ms = d.getMilliseconds()
if(use_date === true) {
let options = {'day':'2-digit','year':'numeric','month':'long','weekday':'long'};
let date = new Date().toLocaleDateString('it-IT', options);
		if(fulldate === "") fulldate = date;
	}
    node.innerHTML =time+":" +ms+
		(use_date?("  "+fulldate):"");
}
let node = document.createElement('div');
////////////
node.id = "Clocktest";

node.title = 'trascina time';

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);
         //mostra nascondi time
    function myFunction1() {
node.style.display = ((node.style.display!='none') ? 'none' : 'block');
}
GM_registerMenuCommand("mostra/nascondi",myFunction1);
////////////
//Make the DIV element draggagle:
dragElement(document.getElementById("Clocktest"));

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;
  }
}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址