Greasy Fork is available in English.

Active Tab Arrow Display

Display an arrow on the title of the currently active tab

  1. // ==UserScript==
  2. // @name Active Tab Arrow Display
  3. // @namespace ActiveTabArrowDisplay
  4. // @description Display an arrow on the title of the currently active tab
  5. // @version 1.1
  6. // @author Kai Krause <kaikrause95@gmail.com>
  7. // @include *
  8. // @run-at document-end
  9. // ==/UserScript==
  10.  
  11. var modifier = "➜";
  12.  
  13. function flashTitle() {
  14. setTimeout(() => {
  15. var title = document.title;
  16. title = title.replace(modifier,"");
  17.  
  18. if (document.hasFocus() || !document.hidden) {
  19. document.title = modifier + " " + title;
  20. } else if (!document.hasFocus() && document.hidden) {
  21. document.title = title;
  22. }
  23. }, 500);
  24. }
  25.  
  26. flashTitle();
  27.  
  28. window.addEventListener("focus", flashTitle, true);
  29. window.addEventListener("blur", flashTitle, true);
  30.  
  31. var titleSel = document.querySelector('title');
  32. var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
  33. var MutationObserverConfig={
  34. childList: true,
  35. subtree: true,
  36. characterData: true
  37. };
  38. var titleObserver = new MutationObserver(function(mutations){
  39. flashTitle();
  40. });
  41. titleObserver.observe(titleSel, MutationObserverConfig);