Website Usage Timer

Shows a timer on any website to track time spent

目前为 2025-03-13 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Website Usage Timer
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description Shows a timer on any website to track time spent
  6. // @author Drewby123
  7. // @match *://*/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. // Create the timer element
  16. const timerBox = document.createElement('div');
  17. timerBox.id = 'site-timer-overlay';
  18. timerBox.style.position = 'fixed';
  19. timerBox.style.bottom = '20px';
  20. timerBox.style.right = '20px';
  21. timerBox.style.background = 'rgba(0, 0, 0, 0.7)';
  22. timerBox.style.color = '#fff';
  23. timerBox.style.padding = '10px 14px';
  24. timerBox.style.borderRadius = '10px';
  25. timerBox.style.fontFamily = 'monospace';
  26. timerBox.style.fontSize = '14px';
  27. timerBox.style.zIndex = '9999';
  28. timerBox.style.boxShadow = '0 2px 8px rgba(0,0,0,0.5)';
  29. timerBox.textContent = 'Time on site: 00:00';
  30.  
  31. document.body.appendChild(timerBox);
  32.  
  33. // Start timer
  34. let seconds = 0;
  35.  
  36. setInterval(() => {
  37. seconds++;
  38. const mins = Math.floor(seconds / 60).toString().padStart(2, '0');
  39. const secs = (seconds % 60).toString().padStart(2, '0');
  40. timerBox.textContent = `Time on site: ${mins}:${secs}`;
  41. }, 1000);
  42. })();