Clock figuccio

clock ore minuti secondi millesimi data

目前为 2020-07-06 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Clock figuccio
  3. // @description clock ore minuti secondi millesimi data
  4. // @version 2.1
  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. var use_date = true;
  16. function updateClock() {
  17. var period = "",
  18. fulldate = "",
  19. date = new Date();
  20. let time = new Date().toLocaleTimeString('en-US', { hour12: false,hour:'2-digit', minute:'2-digit',second:'2-digit',});
  21. let d = new Date();
  22. let ms = d.getMilliseconds()
  23. if(use_date === true) {
  24. let options = {'day':'2-digit','year':'numeric','month':'long','weekday':'long'};
  25. let date = new Date().toLocaleDateString('it-IT', options);
  26. if(fulldate === "") fulldate = date;
  27. }
  28. node.innerHTML =time+":" +ms+
  29. (use_date?(" "+fulldate):"");
  30. }
  31. let node = document.createElement('div');
  32. ////////////
  33. node.id = "Clocktest";
  34.  
  35. node.title = 'trascina time';
  36.  
  37. node.setAttribute("style","cursor:move;padding:4px;background:black;color:lime;font-family: Orbitron;letter-spacing: 2px;top:0;font-size:14px;position:fixed;text-align:center;z-index:999999;border-radius:10px;border:2px solid yellow;");
  38. document.body.appendChild(node);
  39. setInterval(() => updateClock(), 70);
  40. ////////////////////////////////////////////////
  41. function Clock() {
  42. var date = new Date();
  43. var d = new Date();
  44. var mm;
  45. mm = d.getMilliseconds();
  46. var ore = date.toLocaleString('it',{
  47. hour:'2-digit',minute:'numeric',second:'numeric',
  48. });
  49. node2.innerHTML = ore+":"+ mm;;
  50. }
  51. var node2 = document.createElement('div');
  52. node2.id = "b";
  53. node2.setAttribute("style","padding:4px;background:black;color:lime;top:0px;font-family:sans-serif;font-size:14px;position:fixed;text-align:center;z-index:999999;border-radius:10px;border:2px solid yellow;");
  54. document.body.appendChild(node2);
  55. setInterval(() => Clock(), 70);
  56. ////////////////////////////
  57. function Function149() {
  58. if (node.style.display === 'none') {
  59. node.style.display = 'block';
  60. node2.style.display = 'none';
  61. } else {
  62. node.style.display = 'none';
  63. node2.style.display = 'block';
  64. }
  65. }
  66. //GM_registerMenuCommand("mostra data /time",Function149);
  67.  
  68. //funziona cambia data-ora al click
  69. node2.addEventListener("click", Function149);
  70. node.addEventListener("click", Function149);
  71. node.style.display = 'none';
  72.  
  73.  
  74. //mostra nascondi time
  75. // function myFunction1() {
  76. //node.style.display = ((node.style.display!='none') ? 'none' : 'block');
  77. //}
  78. //GM_registerMenuCommand("mostra/nascondi",myFunction1);
  79.  
  80. ////////////
  81. //Make the DIV element draggagle:
  82. dragElement(document.getElementById("Clocktest"));
  83.  
  84. function dragElement(elmnt) {
  85. var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
  86. if (document.getElementById(elmnt.id + "header")) {
  87. /* if present, the header is where you move the DIV from:*/
  88. document.getElementById(elmnt.id + "header").onmousedown = dragMouseDown;
  89. } else {
  90. /* otherwise, move the DIV from anywhere inside the DIV:*/
  91. elmnt.onmousedown = dragMouseDown;
  92. }
  93.  
  94. function dragMouseDown(e) {
  95. e = e || window.event;
  96. e.preventDefault();
  97. // get the mouse cursor position at startup:
  98. pos3 = e.clientX;
  99. pos4 = e.clientY;
  100. document.onmouseup = closeDragElement;
  101. // call a function whenever the cursor moves:
  102. document.onmousemove = elementDrag;
  103. }
  104.  
  105. function elementDrag(e) {
  106. e = e || window.event;
  107. e.preventDefault();
  108. // calculate the new cursor position:
  109. pos1 = pos3 - e.clientX;
  110. pos2 = pos4 - e.clientY;
  111. pos3 = e.clientX;
  112. pos4 = e.clientY;
  113. // set the element's new position:
  114. elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
  115. elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
  116. }
  117.  
  118. function closeDragElement() {
  119. /* stop moving when mouse button is released:*/
  120. document.onmouseup = null;
  121. document.onmousemove = null;
  122. }
  123. }
  124.  
  125.