Time on Tab Title

Display travel time on tab title.

目前为 2023-11-30 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Time on Tab Title
  3. // @namespace
  4. // @version 0.1
  5. // @description Display travel time on tab title.
  6. // @author HesperCroft [2924630]
  7. // @match https://www.torn.com/index.php
  8. // @icon
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. const title = "[Time on Tab Title]: ";
  16.  
  17.  
  18. var span = document.getElementById('countrTravel');
  19.  
  20. if (span) {
  21. var observer = new MutationObserver(function(mutations) {
  22.  
  23. if (document.contains(span)) {
  24. document.title = span.textContent + " Traveling | TORN";
  25. // document.title = span.textContent + " Keep Calm and Code On.";
  26.  
  27. } else {
  28. observer.disconnect();
  29. console.log(title + 'Element with id "countrTravel" not found. Observer disconnected.');
  30. }
  31. });
  32.  
  33. observer.observe(span, { characterData: true, childList: true, subtree: true });
  34. }
  35.  
  36.  
  37. })();