Greasy Fork is available in English.

Twitch Auto Pause Host

Prevents hosted streams from auto playing.

  1. // ==UserScript==
  2. // @name Twitch Auto Pause Host
  3. // @version 0.1
  4. // @description Prevents hosted streams from auto playing.
  5. // @author Luxocracy
  6. // @grant none
  7. // @match https://www.twitch.tv/*
  8. // @namespace https://greatest.deepsurf.us/users/30239
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. var observer = new MutationObserver(function(mutations) {
  13. mutations.forEach(function(mutation) {
  14. // Check if the mutation is the hosting video player being added.
  15. if(mutation.target.classList.contains('video-player-hosting-ui__container')) {
  16. let playButton = document.querySelector('div.pl-controls-bottom.pl-flex.qa-controls-bottom > div.player-buttons-left > button');
  17. // Loop to click the pause button once the stream starts playing.
  18. var pauseLoop = function() {
  19. if((playButton.firstChild.firstChild.dataset.tip.toLowerCase() === "pause")) {
  20. playButton.click(); // Click pause button
  21. } else {
  22. setTimeout(pauseLoop, 500);
  23. }
  24. };
  25. pauseLoop();
  26. }
  27. });
  28. });
  29.  
  30. if (!window.location.pathname.match('directory')) observer.observe(document.querySelector('body'), { childList: true, subtree: true });
  31. })();