🚫 ShortsOff! - YouTube Shorts Remover

Disables elements that lead to YouTube Shorts.

当前为 2024-11-21 提交的版本,查看 最新版本

// ==UserScript==
// @name        🚫 ShortsOff! - YouTube Shorts Remover
// @icon        https://solabs.neocities.org/assets/no_shorts!.png
// @license     GNU GPL v3.0; http://www.gnu.org/licenses/gpl-3.0.txt
// @match       https://www.youtube.com/*
// @version     1.1
// @author      Boon!
// @description Disables elements that lead to YouTube Shorts.
// @namespace https://gf.qytechs.cn/users/1398226
// ==/UserScript==

console.log("[ShortsOff!] Boop!")

// Remove shorts category when searching.
function removeShortsSearchCategory() {
  const elements = document.querySelectorAll('yt-formatted-string[title="Shorts"]');
  elements.forEach(element => {
    if (element) {
      element.parentElement.remove();
    }
  });
}

// Removes the shorts endpoint link at the sidebar.
function removeShortsEndpointLinks() {
  const elements = document.querySelectorAll('a[title="Shorts"]');
  elements.forEach(element => {
    if (element) {
      element.remove();
    }
  });
}

// Removes the recommended shorts at the homepage.
function removeIsShorts() {
  const elements = document.querySelectorAll('[is-shorts]');
  elements.forEach(element => {
    if (element) {
      element.remove();
    }
  });
}

// Removes the recommended shorts at the side while watching a video.
function removeYtdReels() {
  const elements = document.querySelectorAll('ytd-reel-shelf-renderer');
  elements.forEach(element => {
    if (element) {
      element.remove();
    }  });
}

// Main function
function main() {
  removeShortsEndpointLinks();
  removeIsShorts();
  removeYtdReels();
  removeShortsSearchCategory()
}

// Initialize an observer that runs the main function when an element is modified.
const observer = new MutationObserver(main);
observer.observe(document.body, { childList: true, subtree: true });

QingJ © 2025

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