Twitch - Expand your followed channels list automatically

Expand your followed channels list automatically with settings

  1. // ==UserScript==
  2. // @name Twitch - Expand your followed channels list automatically
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.9
  5. // @description Expand your followed channels list automatically with settings
  6. // @author Jens Nordström
  7. // @match https://www.twitch.tv/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=twitch.tv
  9. // @license MIT
  10. // @grant none
  11. // ==/UserScript==
  12. (function() {
  13. 'use strict';
  14.  
  15. // Wait for the DOM to load
  16. function waitForElement(querySelector, timeout) {
  17. return new Promise((resolve, reject) => {
  18. var timer = false;
  19. if (document.querySelectorAll(querySelector).length) return resolve();
  20. const observer = new MutationObserver(() => {
  21. if (document.querySelectorAll(querySelector).length) {
  22. observer.disconnect();
  23. if (timer !== false) clearTimeout(timer);
  24. return resolve();
  25. }
  26. });
  27. observer.observe(document.body, {
  28. childList: true,
  29. subtree: true
  30. });
  31. });
  32. }
  33.  
  34. // Initialize
  35. waitForElement(".side-nav-show-more-toggle__button", 0).then(function() {
  36.  
  37. // Change this value with how many times the followed channel list should be expanded
  38. var expandAmount = 3;
  39.  
  40. for (var i = 0; i < expandAmount; i++) {
  41. document.querySelector(".side-nav-show-more-toggle__button > button").click();
  42. }
  43. })
  44. })();