Last active
June 26, 2023 14:38
-
-
Save jdelamater99/c3d68b8eb8e1fb904fd7dab68aed2165 to your computer and use it in GitHub Desktop.
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* | |
// @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