Youtube Collapse Sidebar

collapse youtube sidebar

目前為 2023-06-11 提交的版本,檢視 最新版本

// ==UserScript==
// @name            Youtube Collapse Sidebar
// @version         0.8
// @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/@*
// @icon            https://cdn-icons-png.flaticon.com/512/7711/7711100.png
// @author          hdyzen
// @run-at          document-start
// @inject-into     page
// @unwrap
// @license         MIT

// ==/UserScript==
(function () {
    ("use strict");

    window.addEventListener("DOMContentLoaded", function () {
        const sections = document.querySelector("#sections");
        let clicked = false; // Variável de controle

        function clickGuide() {
            document.querySelector("#guide-button").click();
        }

        const observer = new MutationObserver(function (mutations) {
            mutations.forEach(function (mutation) {
                if (
                    mutation.type === "childList" &&
                    document.querySelector("#sections") &&
                    !clicked // Verificar se o log ainda não foi exibido
                ) {
                    clickGuide();
                    clicked = true; // Definir a variável de controle como true
                }
            });
        });

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