Clock2

Show time drag

2024-03-10 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name        Clock2
// @description Show time drag
// @author      figuccio
// @version     0.5
// @namespace   https://greasyfork.org/users/237458
// @match       *://*/*
// @grant       GM_addStyle
// @grant       GM_setValue
// @grant       GM_getValue
// @grant       GM_registerMenuCommand
// @require     https://code.jquery.com/jquery-3.6.0.min.js
// @require     https://code.jquery.com/ui/1.12.1/jquery-ui.js
// @icon        https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @license     MIT
// ==/UserScript==
(function() {
 'use strict';
const $ = window.jQuery;
var j = $.noConflict();
const body=document.body;

var todVisible = true; // Variabile per monitorare se l'orologio è visibile o meno

// Funzione per salvare la posizione dell'orologio nella memoria locale
function saveClockPosition(x, y) {
GM_setValue('clockPosition', JSON.stringify({ x: x, y: y }));
}

// Funzione per caricare la posizione dell'orologio dalla memoria locale
function loadClockPosition() {
    const savedPosition = GM_getValue('clockPosition');
    if (savedPosition) {
        const position = JSON.parse(savedPosition);
        tod.style.left = position.x + 'px';
        tod.style.top = position.y + 'px';
    }
}

// Aggiungi comandi di menu per mostrare e nascondere l'orologio
GM_registerMenuCommand("Mostra/Nascondi orologio", function() {
    if (todVisible) {
        $(tod).hide();
        todVisible = false;
    } else {
        $(tod).show();
        todVisible = true;
    }
});

////////////////////////

if( top.location != location ) return;

Number.prototype.pad = function(size)	{
	if( typeof(size) !== "number" ) {
		size = 2;
	}
	var	s = String(this);
	while (s.length < size) {
		s = "0" + s;
	}
	return s;
}

var tod = document.createElement("div");
tod.id = "todClock";

tod.setAttribute(
    "style",
    "top:0;" +
    "color:black;"+
    "font-family:droid sans mono;"+
    "font-size:16pt;"+
    "line-height:20px;"+
    "position:fixed;"+
    "text-align:center;"+
    "z-index:99999999999;"+
    " background-color:green;"+
    "-moz-user-select:none;"+
    "cursor:move;"
);

function tick() {
    var d = new Date();
    var Y = d.getFullYear();
    var M = (d.getMonth()+1).pad();
    var D = d.getDate().pad();
    var h = d.getHours().pad();
    var m = d.getMinutes().pad();
    var s = d.getSeconds().pad();
    var ms = d.getMilliseconds();
    tod.innerHTML=h + ":" + m + ":" + s + ":" + ms + "-" + D + "/" + M + "/" + Y;
}

j(tod).draggable({
    containment: "window", // Assicura che l'elemento draggable sia confinato alla finestra del browser
    stop: function(event, ui) {
    saveClockPosition(ui.position.left, ui.position.top);
    }
});

body.append(tod);

loadClockPosition(); // Carica la posizione dell'orologio dalla memoria locale
tick();
setInterval(tick, 70);

})();