Last active
October 31, 2022 15:42
-
-
Save jdelamater99/40575757e66edb2493362042e469a619 to your computer and use it in GitHub Desktop.
Hide Youtube Shorts from subscription feed
This file contains 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 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