Twitch Auto Theatre Mode

Load Twitch Streams in Theatre Mode Automatically

  1. // ==UserScript==
  2. // @name Twitch Auto Theatre Mode
  3. // @namespace https://greasyfork.org/en/users/935727-kotaless
  4. // @version 1.0
  5. // @description Load Twitch Streams in Theatre Mode Automatically
  6. // @author Kotaless
  7. // @match https://www.twitch.tv/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. // Click to the theatre button
  13. function theatreMode() {
  14. if (document.querySelector("[data-a-target=player-theatre-mode-button]")) {
  15. document.querySelector("[data-a-target=player-theatre-mode-button]").click();
  16. }
  17. }
  18.  
  19. // Execute the function when the page load
  20. setTimeout(theatreMode, 1000);
  21.  
  22. // Execute the function again when the page changes
  23. let lastUrl = location.href;
  24. new MutationObserver(() => {
  25. const url = location.href;
  26. if (url !== lastUrl) {
  27. lastUrl = url;
  28. setTimeout(theatreMode, 1000);
  29. }
  30. }).observe(document, { subtree: true, childList: true });