Skip to content

Instantly share code, notes, and snippets.

@danieloliveira117
Last active August 7, 2023 11:34
Show Gist options
  • Save danieloliveira117/8d129abcc5d744890c9bd55f1c122472 to your computer and use it in GitHub Desktop.
Save danieloliveira117/8d129abcc5d744890c9bd55f1c122472 to your computer and use it in GitHub Desktop.
Hide youtube shorts from subscription page
// ==UserScript==
// @name Hide youtube #shorts
// @namespace https://gist.github.com/danieloliveira117/8d129abcc5d744890c9bd55f1c122472
// @version 1.5
// @description Remove youtube shorts from subscriptions (Only in grid view)
// @author danieloliveira117
// @match https://*.youtube.com/feed/subscriptions
// @grant none
// ==/UserScript==
(function () {
'use strict';
function removeShorts() {
document.querySelectorAll('ytd-rich-shelf-renderer[is-shorts]').forEach(t => {
if (t) {
const elem = t.closest('ytd-rich-section-renderer');
if (elem) {
elem.remove();
console.log('Removed shorts section');
}
}
});
}
const observer = new MutationObserver(removeShorts);
observer.observe(document.querySelector('#page-manager'), { childList: true, subtree: true });
})();
@balintsipter
Copy link

Hi @danieloliveira117 I found the script on greasyfork.org, but it still contains an older version(1.0). Also wouldn't it be better to check for contains instead of endsWith? For me the #shorts is not always at the end.

@danieloliveira117
Copy link
Author

Hi @balintsipter, sorry for the delay I've just updated the script here and on greasyfork, apparently it doesn't update automatically

@gangefors
Copy link

I want to start off by thanking you for a great script.

But there are still some content creators that doesn't label their Shorts properly which doesn't match them using the overlay-style attribute. However, many still adds the #shorts hashtag to the title so appending ,#video-title[title~="#shorts"] to the querySelectorAll string helped me get rid of them.

Just wanted to give my praise and share a minor improvement I made to my local script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment