Skip to content

Instantly share code, notes, and snippets.

@jdelamater99
Last active June 26, 2023 14:38
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/c3d68b8eb8e1fb904fd7dab68aed2165 to your computer and use it in GitHub Desktop.
Save jdelamater99/c3d68b8eb8e1fb904fd7dab68aed2165 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Youtube Hide Shorts
// @namespace http://jdel.us
// @description Hide Youtube Shorts from subscription feed
// @include http://*.youtube.com*
// @include https://*.youtube.com*
// @include http://*.youtu.be*
// @include https://*.youtu.be*
// @version 0.6.1
// @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-rich-item-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