Show me now time

在打开每个网页的时候显示一下当前时间,以及今天已经过去的百分比

目前為 2019-03-11 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Show me now time
  3. // @namespace Show me now time
  4. // @version 0.0.2
  5. // @author 稻米鼠
  6. // @description 在打开每个网页的时候显示一下当前时间,以及今天已经过去的百分比
  7. // @match *://*/*
  8. // @grant none
  9. // @noframes
  10. // ==/UserScript==
  11.  
  12. const oldLoadFun = window.onload
  13. window.onload=function(){
  14. oldLoadFun && oldLoadFun()
  15. const nowTime = new Date()
  16. const hours = nowTime.getHours()
  17. const minutes = nowTime.getMinutes()<10 ? '0'+nowTime.getMinutes() : nowTime.getMinutes()
  18. const progress = (nowTime.getTime()-nowTime.getTimezoneOffset()*60000)%(24*3600*1000)/(24*3600*1000)
  19. console.log(progress)
  20. const progressToShow = (progress*100).toFixed(1)<10 ? '0'+(progress*100).toFixed(1) : (progress*100).toFixed(1)
  21.  
  22. const timer = document.createElement("div")
  23. timer.id = 'please-show-me-now-time'
  24.  
  25. const perLong = window.innerHeight > window.innerWidth ? window.innerWidth/100 : window.innerHeight/100
  26. const progressLong = Math.PI * 28 * perLong * progress
  27. const progressLongLast = Math.PI * 28 * perLong * (1-progress)
  28. const timerStyle = `
  29. <style>
  30. #please-show-me-now-time {
  31. position: fixed;
  32. z-index:99999999;
  33. height: 40vmin;
  34. width: 40vmin;
  35. top: calc(-40vmin - 42px);
  36. left: calc(30vmin - 5px);
  37. opacity: 1;
  38. transition: top .6s;
  39. pointer-events: none;
  40. border: 5px solid rgba(255, 255, 255, .6);
  41. border-top: none;
  42. box-shadow: 0 12px 24px 5px rgba(0, 0, 0, .1);
  43. box-sizing: content-box;
  44. }
  45. #please-show-me-now-time * {
  46. pointer-events: none;
  47. }
  48. </style>
  49. `
  50. timer.innerHTML = timerStyle + `
  51. <svg width="`+40*perLong+`" height="`+40*perLong+`">
  52. <rect x="0" y="0" width="`+40*perLong+`" height="`+40*perLong+`" stroke="transparent" fill="hsl(`+(720*progress)%360+`, 80%, 82%)" stroke-width="0"/>
  53. <rect x="0" y="`+10*perLong+`" width="`+40*perLong+`" height="`+30*perLong+`" stroke="transparent" fill="hsl(`+(720*progress)%360+`, 80%, 84%)" stroke-width="0"/>
  54. <rect x="0" y="`+21*perLong+`" width="`+40*perLong+`" height="`+19*perLong+`" stroke="transparent" fill="hsl(`+(720*progress)%360+`, 80%, 86%)" stroke-width="0"/>
  55. <circle cx="`+20*perLong+`" cy="`+20*perLong+`" r="`+14*perLong+`" stroke-width="`+perLong+`" stroke="rgba(32, 32, 36, .1)" fill="none"></circle>
  56. <circle cx="`+20*perLong+`" cy="`+20*perLong+`" r="`+14*perLong+`" stroke-width="`+perLong+`" stroke="hsl(`+(720*progress+72)%360+`, 60%, 48%)" transform="matrix(0,-1,-1,0,`+40*perLong+`,`+40*perLong+`)" fill="none" stroke-dasharray="`+progressLongLast+` `+progressLong+`"></circle>
  57. <g font-size="`+6*perLong+`" font-family="-apple-system, 'SF UI Text', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', 'Lantinghei SC', 'Source Han Sans', 'Noto Sans CJK', sans-serif, Arial" fill="rgba(72, 72, 80, .8)">
  58. <text x="`+19*perLong+`" y="`+20*perLong+`" style="text-anchor: end" font-weight="400">`+hours+`</text>
  59. <text x="`+20*perLong+`" y="`+20*perLong+`" style="text-anchor: middle" font-weight="400">:</text>
  60. <text x="`+21*perLong+`" y="`+20*perLong+`" style="text-anchor: start" font-weight="200">`+minutes+`</text>
  61. <text x="`+20*perLong+`" y="`+23*perLong+`" style="text-anchor: middle" font-size="`+2*perLong+`" font-weight="400">Today is passed `+progressToShow+`%</text>
  62. </g>
  63. </svg>`
  64. document.body.appendChild(timer)
  65. timer.style.left = (document.body.offsetWidth - timer.offsetWidth)/2 + 'px'
  66. window.setTimeout(()=>{
  67. timer.style.top = 0
  68. }, 100)
  69. window.setTimeout(()=>{
  70. timer.style.top = 'calc(-40vmin - 42px)'
  71. }, 3100)
  72. window.setTimeout(()=>{
  73. document.body.removeChild(timer)
  74. }, 5000)
  75. }

QingJ © 2025

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