Greasy Fork is available in English.

Google Timer Title Update

Automatically updates the title when using Google's timer

  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.3
  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. //launch
  14. (function () {
  15. var container;
  16.  
  17. if (container = document.querySelector("#act-timer-section>div")) {
  18. var timerArea = container.querySelector("div");
  19.  
  20. try {
  21. document.querySelector('link[rel="shortcut icon"]').setAttribute("href", GM_info.script.icon);
  22. } catch (e) {
  23. }
  24.  
  25. [".srg", "#searchform", "#extrares", "#top_nav", "#navcnt", "#appbar"].forEach(function (selector) {
  26. setTimeout(function () {
  27. try {
  28. var el = document.querySelector(selector);
  29. el.parentNode.removeChild(el);
  30. } catch (e) {
  31. console.error(e);
  32. }
  33. }, 0);
  34. });
  35.  
  36. (new MutationObserver(function () {
  37. if (container.classList.contains("act-tim-paused")) {
  38. document.title = "PAUSED";
  39. } else if (container.classList.contains("act-tim-finished")) {
  40. document.title = "FINISHED";
  41. } else {
  42. document.title = timerArea.innerText.trim();
  43. }
  44. })).observe(timerArea, {
  45. childList: true,
  46. attributes: true,
  47. characterData: true,
  48. subtree: true
  49. });
  50. }
  51. })();