🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Greasy Fork is available in English.

📂 缓存分发状态(共享加速已生效)
🕒 页面同步时间:2026/01/05 01:18:21
🔄 下次更新时间:2026/01/05 02:18:21
手动刷新缓存

YouTube + Vorapis – Toggle Video, Comments & Sidebar

Allows toggling the visibility of YouTube videos, comments, and recommended sidebar videos

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name         YouTube + Vorapis – Toggle Video, Comments & Sidebar
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Allows toggling the visibility of YouTube videos, comments, and recommended sidebar videos
// @author       Sefa AVAN
// @license      MIT
// @match        https://www.youtube.com/watch*
// @run-at       document-start
// @grant        GM_registerMenuCommand
// ==/UserScript==

(function() {
    'use strict';

    let videoVisible = true;
    let commentsVisible = false;
    let sidebarVisible = false;

    /*************** CSS to hide comments and sidebar ***************/
    const style = document.createElement('style');
    style.textContent = `
        ytd-comments,
        #comments,
        ytd-item-section-renderer#comments,
        [node-type="comments"],
        [class*="comments"],
        [id*="comments"],
        #secondary,
        #secondary-inner,
        #related,
        ytd-watch-next-secondary-results-renderer,
        [node-type="related"],
        [class*="secondary"],
        [id*="secondary"],
        [class*="related"],
        ytd-compact-video-renderer {
            display: none !important;
        }
        ytd-watch-flexy {
            flex-direction: column !important;
        }
    `;
    document.head.appendChild(style);

    /*************** Functions ***************/
    function toggleVideo() {
        const video = document.querySelector('video');
        if (!video) return;
        videoVisible = !videoVisible;
        video.style.display = videoVisible ? 'block' : 'none';
    }

    function toggleComments() {
        const selectors = [
            "ytd-comments",
            "#comments",
            "ytd-item-section-renderer#comments",
            '[node-type="comments"]',
            '[class*="comments"]',
            '[id*="comments"]'
        ];
        commentsVisible = !commentsVisible;
        selectors.forEach(sel => {
            document.querySelectorAll(sel).forEach(el => {
                el.style.display = commentsVisible ? 'block' : 'none';
            });
        });
    }

    function toggleSidebar() {
        const selectors = [
            "#secondary",
            "#secondary-inner",
            "#related",
            "ytd-watch-next-secondary-results-renderer",
            '[node-type="related"]',
            '[class*="secondary"]',
            '[id*="secondary"]',
            '[class*="related"]',
            "ytd-compact-video-renderer"
        ];
        sidebarVisible = !sidebarVisible;
        selectors.forEach(sel => {
            document.querySelectorAll(sel).forEach(el => {
                el.style.display = sidebarVisible ? 'block' : 'none';
            });
        });
    }

    /*************** Tampermonkey Menu ***************/
    GM_registerMenuCommand("Toggle Video Visibility", toggleVideo);
    GM_registerMenuCommand("Toggle Comments Visibility", toggleComments);
    GM_registerMenuCommand("Toggle Sidebar Visibility", toggleSidebar);

    /*************** MutationObserver ***************/
    const observer = new MutationObserver(() => {
        toggleVideo();
        toggleComments();
        toggleSidebar();
    });
    observer.observe(document.documentElement, { childList: true, subtree: true });

})();