Skip to content

Instantly share code, notes, and snippets.

@PeteHaughie
Created September 7, 2025 10:41
Show Gist options
  • Select an option

  • Save PeteHaughie/222134eb987b75692b58ea52e04835dc to your computer and use it in GitHub Desktop.

Select an option

Save PeteHaughie/222134eb987b75692b58ea52e04835dc to your computer and use it in GitHub Desktop.
TamperMonkey Script to Remove Shorts from YouTube Desktop
// ==UserScript==
// @name Remove YouTube Shorts
// @namespace http://tampermonkey.net/
// @version 2025-08-21
// @description Despite repeatedly telling YouTube I don't want to see Shorts in my feed it keeps shoving them down my throat
// @author Pete Haughie
// @match https://www.youtube.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant none
// ==/UserScript==
// Select the node that will be observed for mutations
const targetNode = document.body;
// Options for the observer (which mutations to observe)
const config = { attributes: true, childList: true, subtree: true };
// Callback function to execute when mutations are observed
const callback = (mutationList, observer) => {
for (const mutation of mutationList) {
if (mutation.type === "childList") {
const shorts = targetNode.querySelectorAll('grid-shelf-view-model');
shorts.forEach(short => {
short.remove();
console.log("removed short");
});
const homeShorts = targetNode.querySelectorAll('ytd-rich-section-renderer');
homeShorts.forEach(short => {
short.remove();
console.log("removed short");
});
const searchShorts = targetNode.querySelectorAll('[overlay-style="SHORTS"]');
searchShorts.forEach(searchShort => {
searchShort.parentElement.parentElement.parentElement.parentElement.parentElement.remove();
console.log("removed search short");
});
const navShort = targetNode.querySelectorAll('.title.style-scope.ytd-guide-entry-renderer');
navShort.forEach(short => {
if (short.textContent === "Shorts") {
short.parentElement.parentElement.parentElement.remove();
console.log("removed short");
}
});
}
}
};
// Create an observer instance linked to the callback function
const observer = new MutationObserver(callback);
(function() {
'use strict';
// Start observing the target node for configured mutations
observer.observe(targetNode, config);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment