您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
移除 YouTube 上的 Shorts 标签、Dismissible 元素、Shorts 链接和 Reel Shelf
当前为
// ==UserScript== // @name Remove Youtube Shorts // @namespace https://github.com/strangeZombies/aweb2mdtool // @version 2024-12-11 // @description 移除 YouTube 上的 Shorts 标签、Dismissible 元素、Shorts 链接和 Reel Shelf // @author StrangeZombies // @match https://www.youtube.com/* // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com // @grant none // ==/UserScript== (function () { 'use strict'; // 需要移除的元素选择器 const selectors = [ 'ytd-mini-guide-entry-renderer[aria-label="Shorts"]', 'div#dismissible.style-scope.ytd-rich-shelf-renderer', 'a#endpoint[title="Shorts"]', 'ytd-reel-shelf-renderer.style-scope.ytd-item-section-renderer', ]; // 移除指定选择器的元素 function removeElements() { selectors.forEach((selector) => { /* eslint-disable-next-line no-undef */ const elements = document.querySelectorAll(selector); elements.forEach((element) => element.remove()); }); } // 页面加载完成后运行 /* eslint-disable-next-line no-undef */ window.addEventListener('load', removeElements); // 监视 DOM 变化以移除可能后续添加的元素 /* eslint-disable-next-line no-undef */ const observer = new MutationObserver(removeElements); /* eslint-disable-next-line no-undef */ observer.observe(document.body, { childList: true, subtree: true }); })();