您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Hides the comment button and the comment count on YouTube Shorts to reduce distractions.
// ==UserScript== // @name YouTube Shorts Comment Hider // @namespace http://tampermonkey.net/ // @version 0.3 // @description Hides the comment button and the comment count on YouTube Shorts to reduce distractions. // @author Gemini (ported to greasyfork by Buck) // @match https://www.youtube.com/shorts/* // @grant none // ==/UserScript== (function() { 'use strict'; // Function to hide the comment button and count function hideCommentSectionElements() { // Target the parent <label> element that contains both the comment button // and the comment count. This is a more robust approach to hide both elements // with a single action. // We look for a label whose child button has an aria-label containing "comments". const commentContainer = document.querySelector('label.yt-spec-button-shape-with-label > button[aria-label*="comments"]')?.closest('label'); // If the container is found, hide it if (commentContainer) { // Set display to 'none' to hide the entire element and its children completely commentContainer.style.display = 'none'; console.log('YouTube Shorts: Comment button and count hidden.'); return true; // Indicate that the elements were found and hidden } console.log('YouTube Shorts: Comment button/count container not found yet.'); return false; // Indicate that the elements were not found } // Use a MutationObserver to watch for changes in the DOM // This is crucial for single-page applications like YouTube where content // changes without a full page reload (e.g., when navigating between Shorts). const observer = new MutationObserver((mutationsList, observer) => { // Iterate over all mutations that occurred for (const mutation of mutationsList) { // Check if nodes were added to the DOM. // This is the most common scenario for dynamically loaded content. if (mutation.addedNodes.length > 0) { // Attempt to hide the elements whenever new nodes are added. // This helps catch the elements when they are dynamically loaded onto the page. hideCommentSectionElements(); } } }); // Start observing the document body for child list changes and subtree changes. // This means it will watch for elements being added or removed anywhere in the DOM. // We don't need to observe attributes specifically here, as we are looking for the // presence of the container itself. observer.observe(document.body, { childList: true, subtree: true }); // Also, run the function once immediately in case the elements are already present on page load. hideCommentSectionElements(); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址