🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Clock h m s ms

clock ore minuti secondi millesimi

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name            Clock   h m s ms
// @description     clock ore minuti secondi millesimi
// @version         0.7
// @match           *://*/*
// @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
// @require         http://code.jquery.com/jquery-latest.js
// @require         https://code.jquery.com/ui/1.13.2/jquery-ui.js
// @license         MIT
// ==/UserScript==
(function() {
    'use strict';
const $ = window.jQuery, body = document.body, id = "clock";
const addZero = (x, n) => x.toString().padStart(n, "0");
let is24HourFormat = GM_getValue("is24HourFormat", true); // Impostazione iniziale: formato 24 ore

const updateClock = () => {
    let d = new Date();
    let hours = d.getHours();
    let ampm = "";
    if (!is24HourFormat) {
        ampm = hours >= 12 ? 'PM' : 'AM';
        hours = hours % 12 || 12; // Converti 24h in 12h
    }
    let h = addZero(hours, 2);
    let m = addZero(d.getMinutes(), 2);
    let s = addZero(d.getSeconds(), 2);
    let ms = addZero(d.getMilliseconds(), 3);
    document.getElementById(id).innerHTML = is24HourFormat
        ? `${h}:${m}:${s}:${ms}`
        : `${h}:${m}:${s}:${ms} ${ampm}`;
};

// Aggiungi il comando per cambiare formato orario
GM_registerMenuCommand("Cambia Formato Orario (12h/24h)", () => {
    is24HourFormat = !is24HourFormat; // Alterna tra 12 ore e 24 ore
    GM_setValue("is24HourFormat", is24HourFormat); // Salva la scelta
});

let clock = $(`<div id="${id}" title="trascina time" style="cursor:move;padding:4px;background:red;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 blue;"></div>`)
    .appendTo(body)
    .draggable({
     containment: "window", // Impedisce di trascinarlo fuori dalla finestra del browser
     stop: (e, ui) => GM_setValue("clockPosition", `${ui.position.left},${ui.position.top}`)
    });
let savedPosition = GM_getValue("clockPosition")?.split(",");
if (savedPosition) clock.css({left: `${savedPosition[0]}px`, top: `${savedPosition[1]}px`});

setInterval(updateClock, 70);
////////////////////////////////
let defaultFontSize = GM_getValue("fontSize", "14px"); // Recupera la dimensione salvata o usa "14px" di default
// Applica la dimensione salvata al caricamento della pagina
clock.css("font-size", defaultFontSize);

GM_registerMenuCommand("Cambia Dimensione Testo", () => {
    let newSize = prompt("Inserisci la dimensione del testo (es: 14px, 20px):", defaultFontSize);
    if (newSize) {
        clock.css("font-size", newSize); // Applica la nuova dimensione
        GM_setValue("fontSize", newSize); // Salva la nuova dimensione
       // alert(`Dimensione del testo aggiornata a ${newSize}`);
    }
});

GM_registerMenuCommand("Mostra/Nascondi Orologio", () => {
    clock.toggle();
});
})();