twitch unrecommend

twitch.tv script to hide recommended nav block

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name           twitch unrecommend
// @version        1.03
// @description    twitch.tv script to hide recommended nav block
// @match          https://*.twitch.tv/*

// @run-at         document-end
// @namespace      https://greasyfork.org/users/1359318
// ==/UserScript==

window.onload = function () {

    document.querySelectorAll(".side-nav-section").forEach(entry => {
        if (entry.ariaLabel !== 'Followed Channels') {
            entry.style.setProperty("display", "none", "important");
        }
    });

    const targetNode = document.getElementById("root");
    const config = { childList: true, subtree: true };

    const callback = (mutationList, observer) => {
        for (const mutation of mutationList) {
            mutation.addedNodes.forEach(entry => {
                if (entry.ariaLabel != null && (entry.ariaLabel === 'Recommended Channels' || entry.ariaLabel.endsWith('Viewers Also Watch'))) {
                    entry.style.setProperty("display", "none", "important");
                }
            });
        }
    };

    const observer = new MutationObserver(callback);
    observer.observe(targetNode, config);

}