网页小时钟

在网页右上角显示当前时间

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

// ==UserScript==
// @name         网页小时钟
// @namespace    https://weirick.github.io
// @version      1.0
// @description  在网页右上角显示当前时间
// @author       RCWei
// @license      GPL-3.0
// @match        *://*/*
// @run-at      document-end
// @require      https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js
// ==/UserScript==

let clockHTML = '<div id="clock" style="position:fixed;top:1vw;right:8vh;display:flex;justify-content:center;align-items:center;-webkit-text-stroke:1px rgba(255,255,255,.8);font-size:4vh;color:rgba(0,144,255,.7);pointer-events:none;z-index:999999999"></div>';

let timeBox = document.createElement('div');
timeBox.innerHTML = clockHTML;
$('html').append(timeBox);

setInterval(() => {
  let now = new Date(), hour = now.getHours(), minute = now.getMinutes();
  if (hour < 10) hour = '0' + hour;
  if (minute < 10) minute = '0' + minute;
  $('#clock').text(hour + ":" + minute) ;
}, 1000);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址