Skip to content

Instantly share code, notes, and snippets.

@jdelamater99
Last active December 10, 2024 14:07
Show Gist options
  • Save jdelamater99/c3d68b8eb8e1fb904fd7dab68aed2165 to your computer and use it in GitHub Desktop.
Save jdelamater99/c3d68b8eb8e1fb904fd7dab68aed2165 to your computer and use it in GitHub Desktop.
Greasemonkey/Tampermonkey script that hides Youtube Shorts & Upcoming from subscription feed
// ==UserScript==
// @name Youtube Hide Shorts & Upcoming
// @namespace http://jdel.us
// @description Hide Youtube Shorts & Upcoming from subscription feed
// @include http://*.youtube.com*
// @include https://*.youtube.com*
// @include http://*.youtu.be*
// @include https://*.youtu.be*
// @version 0.7
// @grant none
// ==/UserScript==
let host = window.location.href;
let url = window.location.pathname;
let ytLinks, ytVidTitles, ytChanName, ytMetaDesc;
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");
ytVidTitles = document.getElementsByTagName("yt-formatted-string");
ytChanName = document.getElementsByClassName("yt-simple-endpoint");
ytMetaDesc = document.getElementsByClassName("ytd-video-meta-block");
for (let i = 0; i < ytLinks.length; i++) {
if (ytLinks[i].innerHTML.search("href=\"/shorts") !== -1) {
ytLinks[i].style.display = "none";
}
if (ytLinks[i].innerHTML.search('aria-label="Upcoming"') !== -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