Timer Watch

Displays the timer on timerminutes.com and also shows a digital clock.

目前为 2022-05-21 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Timer Watch
  3. // @namespace https://greasyfork.org/en/users/670188-hacker09?sort=daily_installs
  4. // @version 1
  5. // @description Displays the timer on timerminutes.com and also shows a digital clock.
  6. // @author hacker09
  7. // @match https://www.timerminutes.com/*
  8. // @icon https://www.timerminutes.com/favicon.ico
  9. // @run-at document-end
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13.  
  14. (function() {
  15. 'use strict';
  16. document.querySelector("#btnreset").style.display = 'none'; //Hides the element
  17. document.querySelector("div.header").style.display = 'none'; //Hides the element
  18. document.querySelector("div.footer").style.display = 'none'; //Hides the element
  19. document.querySelector("#timer-form").style.display = 'none'; //Hides the element
  20. document.querySelector("div.section > div > h1").style.display = 'none'; //Hides the element
  21. document.querySelector("div.section > div > h2").style.display = 'none'; //Hides the element
  22. document.querySelector("div.section > div > h3").style.display = 'none'; //Hides the element
  23. document.querySelectorAll("p").forEach(el => el.style.display = 'none'); //Hides the element
  24. document.querySelectorAll("ul.listh").forEach(el => el.style.display = 'none'); //Hides the element
  25. document.querySelectorAll("div.margin10.center").forEach(el => el.style.display = 'none'); //Hides the element
  26.  
  27. document.querySelector("#result > span").insertAdjacentHTML('afterEnd', `<br><span class="time"></span>`); //Show the time
  28.  
  29. function showTime() { //Creates a new function
  30. var date = new Date(); //Creates a variable to hold the computer date on the local time zone
  31. var h = date.getHours(); //Get the hours in the computer date on the local time zone
  32. var m = date.getMinutes(); //Get the minutes in the computer date on the local time zone
  33. var s = date.getSeconds(); //Get the seconds in the computer date on the local time zone
  34.  
  35. document.querySelector(".time").innerText = h + ":" + m + ":" + s; //Adds the current time to the time element
  36. setTimeout(showTime, 1000); //Update the time every second
  37. } //Finishes the showTime function
  38.  
  39. showTime(); //Runs the showTime function
  40. })();