Clock figuccio

clock ore minuti secondi millesimi data

当前为 2020-06-17 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Clock figuccio
  3. // @description clock ore minuti secondi millesimi data
  4. // @version 1.8
  5. // @include *
  6. // @noframes
  7. // @author figuccio
  8. // @grant GM_setValue
  9. // @grant GM_getValue
  10. // @grant GM_registerMenuCommand
  11. // @icon data:image/gif;base64,R0lGODlhEAAQAKECABEREe7u7v///////yH5BAEKAAIALAAAAAAQABAAAAIplI+py30Bo5wB2IvzrXDvaoFcCIBeeXaeSY4tibqxSWt2RuWRw/e+UQAAOw==
  12. // @namespace https://greasyfork.org/users/237458
  13. // ==/UserScript==
  14. /* short long true=ampm false=24h lingua en-US ok am pm mezzogiorno 12:00 .lingua it mezzogiorno ampm 0:00 */
  15. function updateClock() {
  16. //let time = new Date().toLocaleTimeString();
  17. let time = new Date().toLocaleTimeString('en-US', { hour12: false,hour:'2-digit', minute:'2-digit',second:'2-digit',});
  18. let d = new Date();
  19. let ms = d.getMilliseconds()
  20. let options = {'day':'2-digit','year':'numeric','month':'long','weekday':'long'};
  21. let date = new Date().toLocaleDateString('it-IT', options);
  22. node.innerHTML =time+ ":" +ms+ " "+date;
  23. //node.innerHTML =time+ " "+date;
  24. }
  25. let node = document.createElement('div');
  26. ////////////
  27. node.id = "Clocktest";
  28.  
  29. node.title = 'trascina time';
  30.  
  31. node.setAttribute("style","cursor:move;padding:4px;background:black;color:lime;top:0;font-family:sans-serif;font-size:14px;position:fixed;text-align:center;z-index:999999;border-radius:10px;border:2px solid yellow;");
  32. document.body.appendChild(node);
  33. setInterval(() => updateClock(), 70);
  34. //mostra nascondi time
  35. function myFunction1() {
  36. if (node.style.display === 'none') {
  37. node.style.display = 'block';
  38. } else {
  39. node.style.display = 'none';
  40. }
  41. }
  42. GM_registerMenuCommand("mostra/nascondi",myFunction1);
  43. ////////////
  44. //Make the DIV element draggagle:
  45. dragElement(document.getElementById("Clocktest"));
  46.  
  47. function dragElement(elmnt) {
  48. var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
  49. if (document.getElementById(elmnt.id + "header")) {
  50. /* if present, the header is where you move the DIV from:*/
  51. document.getElementById(elmnt.id + "header").onmousedown = dragMouseDown;
  52. } else {
  53. /* otherwise, move the DIV from anywhere inside the DIV:*/
  54. elmnt.onmousedown = dragMouseDown;
  55. }
  56.  
  57. function dragMouseDown(e) {
  58. e = e || window.event;
  59. e.preventDefault();
  60. // get the mouse cursor position at startup:
  61. pos3 = e.clientX;
  62. pos4 = e.clientY;
  63. document.onmouseup = closeDragElement;
  64. // call a function whenever the cursor moves:
  65. document.onmousemove = elementDrag;
  66. }
  67.  
  68. function elementDrag(e) {
  69. e = e || window.event;
  70. e.preventDefault();
  71. // calculate the new cursor position:
  72. pos1 = pos3 - e.clientX;
  73. pos2 = pos4 - e.clientY;
  74. pos3 = e.clientX;
  75. pos4 = e.clientY;
  76. // set the element's new position:
  77. elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
  78. elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
  79. }
  80.  
  81. function closeDragElement() {
  82. /* stop moving when mouse button is released:*/
  83. document.onmouseup = null;
  84. document.onmousemove = null;
  85. }
  86. }
  87.