Clock2

Show time drag

目前为 2022-07-04 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Clock2
  3. // @description Show time drag
  4. // @author figuccio
  5. // @version 0.3
  6. // @namespace https://greasyfork.org/users/237458
  7. // @match *://*/*
  8. // @grant GM_setValue
  9. // @grant GM_getValue
  10. // @require http://code.jquery.com/jquery-latest.js
  11. // @require https://code.jquery.com/ui/1.12.1/jquery-ui.js
  12. // @license MIT
  13. // ==/UserScript==
  14. let $ = window.jQuery;
  15. var j = $.noConflict();
  16. const body=document.body;
  17.  
  18. if( top.location != location ) return;
  19.  
  20. Number.prototype.pad = function(size) {
  21. if( typeof(size) !== "number" ) {
  22. size = 2;
  23. }
  24. var s = String(this);
  25. while (s.length < size) {
  26. s = "0" + s;
  27. }
  28. return s;
  29. }
  30.  
  31. var tod = document.createElement("div");
  32. tod.id = "todClock";
  33.  
  34. tod.setAttribute(
  35. "style",
  36. "top:0;" +
  37. "color:black;" +
  38. "font-family:droid sans mono;" +
  39. "font-size:16pt;" +
  40. "line-height:20px;" +
  41. "position:fixed;" +
  42. "text-align:center;" +
  43. "z-index:99999999999;" +
  44. " background-color:green;"+
  45. "-moz-user-select:none;"+
  46. "cursor:move;"
  47. );
  48.  
  49. function tick() {
  50. var d = new Date();
  51. var Y = d.getFullYear();
  52. var M = (d.getMonth()+1).pad();
  53. var D = d.getDate().pad();
  54. var h = d.getHours().pad();
  55. var m = d.getMinutes().pad();
  56. var s = d.getSeconds().pad();
  57. tod.innerHTML = h + ":" + m + ":" + s+ "*"+D + "/" + M + "/" + Y;
  58. }
  59. j(tod).draggable();
  60. body.append(tod);
  61.  
  62. tick();
  63. setInterval(tick, 1000);
  64.  
  65. $('html body').append(tod);
  66.