Skip to content

Instantly share code, notes, and snippets.

@jdelamater99
Last active October 31, 2022 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdelamater99/40575757e66edb2493362042e469a619 to your computer and use it in GitHub Desktop.
Save jdelamater99/40575757e66edb2493362042e469a619 to your computer and use it in GitHub Desktop.
Hide Youtube Shorts from subscription feed
// ==UserScript==
// @name Youtube Hide Shorts
// @namespace http://jdel.us
// @description Hide Youtube Shorts from subscription feed
// @include http://*.youtube.com*
// @include https://*.youtube.com/feed*
// @include http://*.youtu.be*
// @include https://*.youtu.be*
// @version 0.5
// @grant none
// ==/UserScript==
let host = window.location.href;
let url = window.location.pathname;
let ytLinks;
let timer = 0;
console.log ( 'hide shorts start' );
timer = setTimeout(() => {
hideYTShorts();
}, 500);
window.addEventListener("scroll", hideYTShorts);
function hideYTShorts(){
ytLinks = document.getElementsByTagName("ytd-grid-video-renderer");
for (let i=0; i<ytLinks.length; i++){
if ( ytLinks[i].innerHTML.search( "href=\"/shorts" ) !== -1 ){
ytLinks[i].style.display = "none";
}
}
if (timer) {
clearTimeout(timer);
timer = 0;
}
}
console.log ( 'hidden shorts end' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment