Last active
August 7, 2023 11:34
-
-
Save danieloliveira117/8d129abcc5d744890c9bd55f1c122472 to your computer and use it in GitHub Desktop.
Hide youtube shorts from subscription page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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 }); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 thequerySelectorAll
string helped me get rid of them.Just wanted to give my praise and share a minor improvement I made to my local script.