🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

YouTube Cleaner: Remove Playables & Shorts (Home + Search + Watch)

Removes "YouTube Playables" and Shorts sections from the YouTube homepage, search results, and watch pages.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name         YouTube Cleaner: Remove Playables & Shorts (Home + Search + Watch)
// @namespace    https://www.youtube.com
// @version      1.4.1
// @description  Removes "YouTube Playables" and Shorts sections from the YouTube homepage, search results, and watch pages.
// @license      Custom: Free for personal use, commercial use prohibited.
// @match        https://www.youtube.com/
// @match        https://www.youtube.com/results?search_query=*
// @match        https://www.youtube.com/watch*
// @grant        none
// @icon         https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @homepageURL  https://greasyfork.org/en/scripts/541869-youtube-cleaner-remove-playables-shorts-home-search-watch
// @supportURL   https://greasyfork.org/en/scripts/541869-youtube-cleaner-remove-playables-shorts-home-search-watch/feedback
// ==/UserScript==

(function () {
  'use strict';

  const DEBUG = false;

  const homepageBlockedTitles = [
    'YouTube Playables',
    'Shorts'
  ];

  function removeHomepageSections() {
    const allTitles = document.querySelectorAll('span#title');
    allTitles.forEach(span => {
      const titleText = span.textContent.trim();
      if (homepageBlockedTitles.includes(titleText)) {
        const section = span.closest('ytd-rich-section-renderer');
        if (section) {
          section.remove();
          if (DEBUG) console.log(`[YT Cleaner] Removed homepage section: "${titleText}"`);
        }
      }
    });
  }

  function removeSearchAndWatchShorts() {
    // Remove entire Shorts shelf sections
    const allTitles = document.querySelectorAll('span#title');
    allTitles.forEach(span => {
      const titleText = span.textContent.trim();
      if (/shorts/i.test(titleText)) {
        const reel = span.closest('ytd-reel-shelf-renderer');
        if (reel) {
          reel.remove();
          if (DEBUG) console.log(`[YT Cleaner] Removed Shorts shelf: "${titleText}"`);
        }
      }
    });

    // Remove individual Shorts disguised as regular results
    const shortLinks = document.querySelectorAll('a#video-title[href^="/shorts/"]');
    shortLinks.forEach(link => {
      const videoCard = link.closest('ytd-video-renderer');
      if (videoCard) {
        videoCard.remove();
        if (DEBUG) console.log(`[YT Cleaner] Removed Shorts video card with href: "${link.href}"`);
      }
    });
  }

  function init() {
    const url = location.href;

    if (url === 'https://www.youtube.com/') {
      removeHomepageSections();
    }

    if (
      url.startsWith('https://www.youtube.com/results?search_query=') ||
      url.startsWith('https://www.youtube.com/watch')
    ) {
      removeSearchAndWatchShorts();
    }
  }

  init();

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