您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Mostra un orologio in un angolo di ogni pagina web.
当前为
// ==UserScript== // @name showClock figuccio // @namespace https://greasyfork.org/users/237458 // @description Mostra un orologio in un angolo di ogni pagina web. // @include * // @author figuccio // @version 0.3 // @grant GM_setValue // @grant GM_getValue // @grant GM_registerMenuCommand // @noframes // ==/UserScript== makeMenuToggle("simpleClock", false, "Mostra l'orologio senza bordo nello stile di colore della pagina web", "mostra orologio con bordo e sfondo colorato", ); makeMenuToggle("runningClock", true, "Orologio in esecuzione", "Orologio non in esecuzione (Tempo sul caricamento della pagina)", ); makeMenuToggle("showSeconds", false, "mostra Secondi", "Nascondi secondi", ); makeMenuToggle("rightleft", true, "Orologio sul lato destro►", "Orologio sul lato sinistro◄", ); makeMenuToggle("bottomtop", true, "Orologio in fondo alla pagina↕", "Orologio all'inizio della pagina↕", ); makeMenuToggle("displayhide", true, "Mostra orologio", "Nascondi l'orologio", ); makeMenuToggle("updateCheck", false, "Verifica aggiornamenti automaticamente", "Non controllare automaticamente gli aggiornamenti", ); if (rightleft) horizontal = "right"; else horizontal = "left"; if (bottomtop) vertical = "bottom"; else vertical = "top"; if (displayhide) displayClock = "block"; else displayClock = "none"; // imposta intervallo di aggiornamento (in secondi) if (showSeconds) var updateInterval = 0.1; else var updateInterval = 10; // menuGM functions // --------------------------------------------------------------------- function makeMenuToggle(key, defaultValue, toggleOn, toggleOff, prefix) { // Carica il valore corrente in variabile window[key] = GM_getValue(key, defaultValue); //Attiva / disattiva menu GM_registerMenuCommand((prefix ? prefix+": " : "") + (window[key] ? toggleOff : toggleOn), function() { GM_setValue(key, !window[key]); location.reload(); }); } // mostra l'orologio iniziale e prepara la data // --------------------------------------------------------------------- function showClock() { var jetzt = new Date(); // time var zeit = jetzt.getHours() +':'; if (jetzt.getMinutes() < 10) zeit = zeit + '0'; zeit = zeit + jetzt.getMinutes(); if (showSeconds) { zeit=zeit+':' if (jetzt.getSeconds() < 10) zeit = zeit + '0'; zeit=zeit+jetzt.getSeconds(); } if (document.getElementById("clockDiv")) document.getElementById("clockDiv").innerHTML = zeit; // date var weekdays = new Array("Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"); var months = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dez"); var datum = "(" + weekdays[jetzt.getDay()] + ") " + months[jetzt.getMonth()] + " " + jetzt.getDate() + ", " + jetzt.getFullYear(); + "." if (document.getElementById("dateDiv")) document.getElementById("dateDiv").innerHTML = datum; } // creare elementi function createElements() { if (simpleClock) { clockStyle = "position: fixed; "+horizontal+": 0px; "+vertical+": 0px; font-family:arial; font-size: 18px; z-index:99999; width:auto; padding-left:2px; padding-right:2px; "; dateStyle = "position: fixed; "+horizontal+": 0px; "+vertical+": 20px; font-family:arial; font-size: 18px; z-index:99999; width:auto; padding-left:2px; padding-right:2px; display: none; "; } else { clockStyle = "position: fixed; "+vertical+": 0px; font-family:arial; font-size: 18px; z-index:99999;cursor:move; background-color:red; color:white; border: 1px solid black; width:auto; padding-left:2px; padding-right:2px; "; dateStyle = "position: fixed;"+horizontal+": 0px; "+vertical+": 0px; font-family:arial; font-size: 18px; z-index:99999; background-color:yellow; color:black; border: 1px solid blue; width:auto; padding-left:2px; padding-right:2px; display: none; "; } // creare un elemento orologio var clock = document.createElement('div'); clock.id = "clockDiv"; clock.style.cssText = clockStyle; if (document.getElementsByTagName('body')[0]) document.getElementsByTagName('body')[0].appendChild(clock); // creare un elemento data var dateEl = document.createElement('div'); dateEl.id = "dateDiv"; dateEl.style.cssText = dateStyle; if (document.getElementsByTagName('body')[0]) document.getElementsByTagName('body')[0].appendChild(dateEl); // nascondi al clic del mouse lorologio disattivato rimosso none da style.display var wegmachen = document.createAttribute("onClick"); wegmachen.nodeValue = "document.getElementById('clockDiv').style.display = '';"; if (document.getElementsByTagName('body')[0]) document.getElementById("clockDiv").setAttributeNode(wegmachen); // show date var showDate = document.createAttribute("onMouseOver"); showDate.nodeValue = "document.getElementById('dateDiv').style.display = 'block'; "; if (document.getElementsByTagName('body')[0]) document.getElementById("clockDiv").setAttributeNode(showDate); // hide date var hideDate = document.createAttribute("onMouseOut"); hideDate.nodeValue = "document.getElementById('dateDiv').style.display = 'none';"; if (document.getElementsByTagName('body')[0]) document.getElementById("clockDiv").setAttributeNode(hideDate); // aggiungi stile per la stampa var head, style; head = document.getElementsByTagName('head')[0]; if (!head) { return; } style = document.createElement('style'); style.type = 'text/css'; style.innerHTML = "@media print {div#clockDiv {display:none;}} @media screen {div#clockDiv {display:"+displayClock+";}}"; head.appendChild(style); } // aggiorna l'orologio function updateClockDiv() { var updateClock = window.setInterval( function(){ var jetzt = new Date(); // time var zeit = jetzt.getHours() +':'; if (jetzt.getMinutes() < 10) zeit = zeit + '0'; zeit = zeit + jetzt.getMinutes(); if (showSeconds) { zeit=zeit+':' if (jetzt.getSeconds() < 10) zeit = zeit + '0'; zeit=zeit+jetzt.getSeconds(); } document.getElementById("clockDiv").innerHTML = zeit; // data al passaggio mouse var weekdays = new Array("Domenica", "Lunedi", "Martedi", "Mercoledi", "Giovedi", "Venerdi", "Sabato"); var months = new Array("Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"); var datum = weekdays[jetzt.getDay()]+ " - " + months[jetzt.getMonth()] + " " + jetzt.getDate() + " - " + jetzt.getFullYear(); + "." document.getElementById("dateDiv").innerHTML = datum; }, updateInterval*1000); } createElements(); showClock(); if (updateCheck) { checkForUpdates(); } //aggiornare l'orologio in un determinato intervallo, se desiderato if (runningClock) { updateClockDiv(); } ////////////// //Make the DIV element draggagle: dragElement(document.getElementById("clockDiv")); 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; } }