time

ora-data

  1. // ==UserScript==
  2. // @name time
  3. // @namespace https://greasyfork.org/users/237458
  4. // @version 10.3
  5. // @description ora-data
  6. // @author figuccio
  7. // @match *://*/*
  8. // @grant GM_addStyle
  9. // @grant GM_setValue
  10. // @grant GM_getValue
  11. // @noframes
  12. // @icon data:image/gif;base64,R0lGODlhEAAQAKECABEREe7u7v///////yH5BAEKAAIALAAAAAAQABAAAAIplI+py30Bo5wB2IvzrXDvaoFcCIBeeXaeSY4tibqxSWt2RuWRw/e+UQAAOw==
  13. // @grant GM_registerMenuCommand
  14. // @require http://code.jquery.com/jquery-latest.js
  15. // @require https://code.jquery.com/ui/1.13.2/jquery-ui.js
  16. // @license MIT
  17. // ==/UserScript==
  18. (function() {
  19. 'use strict';
  20. var $ = window.jQuery;
  21. $(document).ready(function() {
  22. // Recupera la posizione salvata del box
  23. var boxPosition = GM_getValue("boxPosition");
  24. var box = $("<div class='timebox' title='Sposta col mouse' id='testtimebox'><div class='day' id='day'></div><div class='time' id='time'></div></div>").css({
  25. "position": "fixed",
  26. "top": boxPosition ? boxPosition.top : "0px",
  27. "left": boxPosition ? boxPosition.left : "930px",
  28. "z-index": "99999999999",
  29. "width": "90px",
  30. "height": "auto",
  31. "margin": "0px",
  32. "text-align": "center",
  33. "background-color": "gold",
  34. "border-radius": "10px",
  35. "border": "2px solid red",
  36. "font-size":"15px",
  37. "color":"red"
  38. }).draggable({
  39. containment: "window", // Limita il movimento all'interno della finestra del browser
  40. // Salva la posizione del box quando viene rilasciato
  41. stop: function(event, ui) {
  42. GM_setValue("boxPosition", {
  43. top: ui.position.top + "px",
  44. left: ui.position.left + "px"
  45. });
  46. }
  47. });
  48.  
  49. $("body").append(box);
  50.  
  51. function updateTime() {
  52. var date = new Date();
  53. var year = date.getFullYear();
  54. var month = (date.getMonth() + 1).toString().padStart(2, '0');
  55. var day = date.getDate().toString().padStart(2, '0');
  56. var hour = date.getHours().toString().padStart(2, '0');
  57. var min = date.getMinutes().toString().padStart(2, '0');
  58. var sec = date.getSeconds().toString().padStart(2, '0');
  59. var millisec = date.getMilliseconds().toString().padStart(3, '0');
  60.  
  61. $("#day").text(`${day}-${month}-${year}`);
  62. $("#time").text(`${hour}:${min}:${sec}:${millisec}`);
  63. }
  64.  
  65. updateTime();
  66. setInterval(updateTime, 80); // Aggiorna ogni millisecondo
  67. });
  68.  
  69. function toggleTimeBox() {
  70. $(".timebox").toggle();
  71. }
  72. GM_registerMenuCommand("Mostra/Nascondi Box", toggleTimeBox);
  73. })();