Clock figuccio

clock ore minuti secondi

目前為 2019-01-08 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Clock figuccio
// @description clock ore minuti secondi
// @version     1.0.1
// @include     *
// @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
// ==/UserScript==

/*==================================================================================*/
const clockSettings = {
  opacity: '',       // Controls CSS Opacity and needs a value from 0 to 1
  fontSize: '20px',   // Sets the size of the clock.
  is12hour: false,       // Toggles between 24 hour or 12 hour clock.
  font: 'Arial',        // Allow a custom font
  }
/*==================================================================================*/

function setStyles(styles) {
  styles.forEach(style => node.style.setProperty(style.name, style.value));
}

function changeOpacity(newOpacity){
  node.style.setProperty('opacity', newOpacity);
}
function updateClock() {
  let date = new Date();
  let time = date.toLocaleString('ita', {
    hour: 'numeric',
    minute: 'numeric',
    second:  'numeric',
    day :'numeric',
    month :'numeric',
    year:'numeric',
    weekday:'long',
    hour12: clockSettings.is12hour
  });
  node.innerHTML = time;
}

function isFullscreen() {
  return (window.fullScreen ||
    (window.innerWidth == screen.width && window.innerHeight == screen.height) ||
    (window.innerWidth >= screen.width && window.innerHeight >= screen.height) || /* Fix for chrome when zoom is < 100%  */
    (!window.screenTop && !window.screenY))
}

let node = document.createElement('div');
let textnode = document.createTextNode('');
node.appendChild(textnode);
setStyles([
  {name: 'position', value: 'fixed'},
  { name: 'bottom', value: '0' },
  { name: 'background-color', value: 'red' },
  { name: 'color', value: 'white' },
  { name: 'z-index', value: '99999' },
  { name: 'font-size', value: clockSettings.fontSize  },
  { name: 'padding', value: '1px 4px' },
  { name: 'border-radius', value: '10px' },/* bordi arrotondati */
  { name: 'border', value: '1px solid blue' },/* colore bordo */
  { name:  'margin',value: '600px 500px' }, /* 600altezza 500larghezza  */
  { name: 'font-family', value: '"' + clockSettings.font + '", sans-serif'  },
]);
document.body.appendChild(node);

setInterval(() => updateClock(), 1000);
window.addEventListener('resize', () => changeOpacity((isFullscreen())? clockSettings.opacity : '0'));
node.addEventListener('mouseout', () => changeOpacity(clockSettings.opacity));
node.addEventListener('mouseover',() => changeOpacity(''));