Remove Youtube Shorts

Remove YouTube Shorts tags, dismissible elements, Shorts links, and Reel Shelf

目前为 2024-12-30 提交的版本。查看 最新版本

// ==UserScript==
// @name        Remove Youtube Shorts
// @namespace   https://github.com/strangeZombies/aweb2mdtool
// @version     2024-12-30
// @description Remove YouTube Shorts tags, dismissible elements, Shorts links, and 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) => {
      document.querySelectorAll(selector).forEach((element) => element.remove());
    });
  }

  let debounceTimeout;
  function debouncedRemoveElements() {
    clearTimeout(debounceTimeout);
    debounceTimeout = setTimeout(removeElements, 200);
  }

  window.addEventListener('load', removeElements);

  const observer = new MutationObserver(debouncedRemoveElements);
  observer.observe(document.body, { childList: true, subtree: true });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址