时间显示

在页面上添加时间,便于了解时间(24小时制),时间上停留显示日期

  1. // ==UserScript==
  2. // @name 时间显示
  3. // @namespace 戈小戈
  4. // @version 0.1.0
  5. // @description 在页面上添加时间,便于了解时间(24小时制),时间上停留显示日期
  6. // @author 戈小戈
  7. // @include *.*/*
  8. // @match *://*
  9. // @require https://code.jquery.com/jquery-latest.js
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. var a;
  16. var x;
  17. var y;
  18. var gxg_html = "<div id='ptime' style='font-size:30px;left:0;top:100px;cursor:pointer;z-index:99999999999999999999;display:block;position:fixed;text-align:center;overflow:visible'></div>";
  19. $("body").append(gxg_html);
  20. var mytime = setInterval(function () {
  21. getTime();
  22. },100);
  23. function getTime() {
  24.  
  25. var d = new Date();
  26. var t = d.toLocaleTimeString('chinese',{hour12:false})+'.'+parseInt(Number(d.getMilliseconds('chinese',{hour12:false}))/100);
  27. document.getElementById("ptime").innerHTML = t;
  28. }
  29.  
  30. $("body").mousemove(function(){
  31. x=event.pageX;
  32. y=event.pageY;
  33. });
  34. $("#ptime").mousedown(function(){
  35. a=0;
  36. var timer = setInterval(function(){
  37. if(a==0){
  38. document.getElementById("ptime").style.left=x+'px';
  39. document.getElementById("ptime").style.top=y+'px';
  40. }
  41. $("#ptime").mouseup(function(){
  42. a=1;
  43. });
  44. },0.1)
  45. });
  46. var timerr = setInterval(function(){
  47. var d = new Date();
  48. document.getElementById("ptime").title=d.toLocaleDateString();
  49. },1000)
  50. // Your code here...
  51. })();

QingJ © 2025

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