Expand your followed channels list automatically with settings
当前为
// ==UserScript==
// @name Twitch - Expand your followed channels list automatically
// @namespace http://tampermonkey.net/
// @version 0.4
// @description Expand your followed channels list automatically with settings
// @author Jens Nordström
// @match https://www.twitch.tv/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=twitch.tv
// @license MIT
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Wait for the DOM to load
function waitForElement(querySelector, timeout) {
return new Promise((resolve, reject) => {
var timer = false;
if (document.querySelectorAll(querySelector).length) return resolve();
const observer = new MutationObserver(() => {
if (document.querySelectorAll(querySelector).length) {
observer.disconnect();
if (timer !== false) clearTimeout(timer);
return resolve();
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});
});
}
// Initialize
waitForElement(".gBLUEB", 0).then(function() {
// Change this value with how many times the "Show More" button should be clicked to expand the list
// Min 0 and Max 10 times
var expandAmount = 1;
function settings(trigger) {
var target = document.querySelector(".hGjPna");
for (var i = 0; i < trigger; i++) {
target.click();
}
}
switch (expandAmount) {
case 0:
return;
break;
case 1:
settings(expandAmount);
break;
case 2:
settings(expandAmount);
break;
case 3:
settings(expandAmount);
break;
case 4:
settings(expandAmount);
break;
case 5:
settings(expandAmount);
break;
case 6:
settings(expandAmount);
break;
case 7:
settings(expandAmount);
break;
case 8:
settings(expandAmount);
break;
case 9:
settings(expandAmount);
break;
case 10:
settings(expandAmount);
break;
default:
alert("Settings value out of bounds, Min 0 and Max 10");
break;
}
})
})();