Google Timer Title Update

Automatically updates the title when using Google's timer

当前为 2016-09-02 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Google Timer Title Update
  3. // @namespace org.alorel.googletimer
  4. // @author Alorel <a.molcanovas@gmail.com>
  5. // @description Automatically updates the title when using Google's timer
  6. // @include https://*google.*/search?*
  7. // @version 1.0
  8. // @icon https://cdn.rawgit.com/AlorelUserscripts/google-timer-title-switcher/master/icon.png
  9. // @run-at document-end
  10. // @grant GM_info
  11. // ==/UserScript==
  12.  
  13. (function (document, MutationObserver) {
  14. var timerArea,
  15. container,
  16. title;
  17.  
  18. if (container = document.querySelector("#act-timer-section>div")) {
  19. timerArea = container.querySelector("div");
  20. title = document.querySelector("head>title");
  21.  
  22. (function () {
  23. var faviconElement;
  24. if (faviconElement = document.querySelector('link[rel="shortcut icon"]')) {
  25. faviconElement.setAttribute("href", GM_info.script.icon);
  26. faviconElement = null;
  27. }
  28. })();
  29.  
  30. (new MutationObserver(function () {
  31. if (container.classList.contains("act-tim-paused")) {
  32. title.innerText = "PAUSED";
  33. } else if (container.classList.contains("act-tim-finished")) {
  34. title.innerText = "FINISHED";
  35. } else {
  36. title.innerText = timerArea.innerText.trim();
  37. }
  38. })).observe(timerArea, {
  39. childList: true,
  40. attributes: true,
  41. characterData: true,
  42. subtree: true
  43. });
  44. }
  45. })(document, MutationObserver);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址