Youtube Collapse Sidebar

collapse youtube sidebar

目前為 2023-07-12 提交的版本,檢視 最新版本

// ==UserScript==
// @name            Youtube Collapse Sidebar
// @version         1.2
// @description     collapse youtube sidebar
// @namespace       https://greasyfork.org/users/821661
// @match           https://www.youtube.com/
// @match           https://www.youtube.com/results?*
// @match           https://www.youtube.com/@*
// @match           https://www.youtube.com/feed/subscriptions
// @icon            https://cdn-icons-png.flaticon.com/512/7711/7711100.png
// @run-at          document-idle
// @author          hdyzen
// @license         MIT
// ==/UserScript==
(function () {
    ("use strict");

    const observer = new MutationObserver((mutations) => {
        mutations.forEach((mutation) => {
            const guide = document.querySelector("#guide");
            if (mutation.type === "childList" && guide.hasAttribute("opened")) {
                const guideButton = document.querySelector("#guide-button");
                guide.removeAttribute("opened");
                observer.disconnect();
            }
        });
    });

    observer.observe(document.body, {
        childList: true,
    });
})();