Block + Redirect YouTube Shorts

Hide YouTube Shorts everywhere and redirect shorts URLs to normal watch pages.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Block + Redirect YouTube Shorts
// @namespace    http://github.com/chunjee
// @version      0.1.0
// @description  Hide YouTube Shorts everywhere and redirect shorts URLs to normal watch pages.
// @author       Chunjee
// @match        https://www.youtube.com/*
// @grant        none
// @run-at       document-start
// @license      MIT
// ==/UserScript==

(function() {
	'use strict';

	// 🚫 Redirect if on a Shorts URL
	if (location.pathname.startsWith('/shorts/')) {
		location.replace('https://www.youtube.com/');
		return;
	}

	// 🧹 Hide Shorts previews everywhere else
	const observer = new MutationObserver(() => {
		document.querySelectorAll('a[href*="/shorts/"]').forEach(link => {
			let container = link.closest(
				'ytd-grid-video-renderer, ytd-rich-item-renderer, ytd-video-renderer, ytd-compact-video-renderer, ytd-reel-shelf-renderer, ytd-rich-grid-media'
			);
			if (!container) container = link;
			container.style.display = 'none';
		});
	});

	observer.observe(document, {
		childList: true,
		subtree: true
	});
})();