🚫 ShortsOff! - YouTube Shorts Remover

Disables elements that lead to YouTube Shorts.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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://greasyfork.org/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 });