Twitch - Expand your followed channels list automatically

Expand your followed channels list automatically with settings

当前为 2022-11-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Twitch - Expand your followed channels list automatically
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.4
  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(".gBLUEB", 0).then(function() {
  36.  
  37. // Change this value with how many times the "Show More" button should be clicked to expand the list
  38. // Min 0 and Max 10 times
  39. var expandAmount = 1;
  40.  
  41. function settings(trigger) {
  42. var target = document.querySelector(".hGjPna");
  43. for (var i = 0; i < trigger; i++) {
  44. target.click();
  45. }
  46. }
  47.  
  48. switch (expandAmount) {
  49. case 0:
  50. return;
  51. break;
  52. case 1:
  53. settings(expandAmount);
  54. break;
  55. case 2:
  56. settings(expandAmount);
  57. break;
  58. case 3:
  59. settings(expandAmount);
  60. break;
  61. case 4:
  62. settings(expandAmount);
  63. break;
  64. case 5:
  65. settings(expandAmount);
  66. break;
  67. case 6:
  68. settings(expandAmount);
  69. break;
  70. case 7:
  71. settings(expandAmount);
  72. break;
  73. case 8:
  74. settings(expandAmount);
  75. break;
  76. case 9:
  77. settings(expandAmount);
  78. break;
  79. case 10:
  80. settings(expandAmount);
  81. break;
  82. default:
  83. alert("Settings value out of bounds, Min 0 and Max 10");
  84. break;
  85. }
  86. })
  87. })();