Digital Clock & Date figuccio

digital clock e la data facoltativa in basso a destra sullo schermo

当前为 2020-06-23 提交的版本,查看 最新版本

// ==UserScript==
// @name           Digital Clock & Date figuccio
// @namespace https://gf.qytechs.cn/users/237458
// @description    digital clock e la data facoltativa in basso a destra sullo schermo
// @include     *
// @version        1.4
// @noframes
// @grant          GM_getValue
// @grant          GM_registerMenuCommand
// @grant          GM_setValue
// ==/UserScript==
var use_date = true; // "true" si date , "false" no data
if(document.getElementById("digital_clock") !== null) throw "";
var time_box = document.createElement("div");
time_box.setAttribute("id", "digital_clock");
time_box.setAttribute("style","position:fixed;padding:5px;cursor:move;color:lime;background:black;border:1px solid red;border-radius:6px;font-size:14px;font-family:sans-serif, arial, verdana; z-index:99999999;");
document.body.insertBefore(time_box, document.body.firstChild);
time_box.title = 'trascina time';
function setTime() {
	var period = "",
		fulldate = "",
		date = new Date();
let time = new Date().toLocaleTimeString('en-US', {hour12: false,hour:'2-digit', minute:'2-digit',second:'2-digit',});
	// Gestire la disposizione della data
	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;
	}

	time_box.textContent = time+period+
		(use_date?("  "+fulldate):""); // Aggiungi data se abilitato
	window.setTimeout(setTime, 1000);
}
window.setTimeout(setTime, 0);
                 //mostra nascondi orologio
                function myFunctiont() {
  time_box.style.display = ((time_box.style.display!='none') ? 'none' : 'block');
}
GM_registerMenuCommand("nascondi/mostra",myFunctiont);

////////////
//Make the DIV element draggagle:
dragElement(document.getElementById("digital_clock"));

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或关注我们的公众号极客氢云获取最新地址