Skip to content

Instantly share code, notes, and snippets.

@xPaw
Last active March 8, 2026 00:10
Show Gist options
  • Select an option

  • Save xPaw/6324624 to your computer and use it in GitHub Desktop.

Select an option

Save xPaw/6324624 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @version 1.4.1
// @name Hide watched videos on YouTube
// @icon https://www.youtube.com/favicon.ico
// @match https://www.youtube.com/*
// @exclude https://www.youtube.com/embed/*
// @exclude https://www.youtube.com/api/*
// @namespace https://gist.github.com/xPaw/6324624
// @updateURL https://gist.github.com/xPaw/6324624/raw/YoutubeHideWatched.user.js
// @downloadURL https://gist.github.com/xPaw/6324624/raw/YoutubeHideWatched.user.js
// @grant none
// ==/UserScript==
const app = document.querySelector( 'ytd-app' );
function HideVideos( a )
{
app.querySelectorAll( 'ytd-browse[page-subtype="subscriptions"] ytd-thumbnail-overlay-resume-playback-renderer' ).forEach( element =>
{
// Find the container element for this video
let tagName;
do
{
element = element.parentNode;
tagName = element.tagName.toLowerCase();
}
while( tagName !== 'ytd-grid-video-renderer' && tagName !== 'ytd-item-section-renderer' );
element.hidden = true;
} );
}
function ProcessPage()
{
if( !window.location.pathname.startsWith( '/feed/subscriptions' ) )
{
return;
}
const list = app.querySelector( 'ytd-section-list-renderer' );
if( list.dataset.hooked )
{
return;
}
list.dataset.hooked = true;
list.addEventListener( 'yt-next-continuation-data-updated', HideVideos );
// TODO: Find an event to fix this
new MutationObserver( HideVideos ).observe( list, { childList: true, subtree: true } );
}
if( app )
{
app.addEventListener( 'yt-navigate-finish', ProcessPage );
}
ProcessPage();
@MerlinScheurer

Copy link
Copy Markdown

Works now.
Thank you very much ;)

@alexandreraufast

Copy link
Copy Markdown

For those wondering, this script doesn't hide video permanently. If you reload, all videos will be back there.

@Osahashi

Copy link
Copy Markdown

It stops working for me/doesn't hide watched videos anymore, maybe YouTube change something? Could you please check/update the script? Thanks!

@Osahashi

Osahashi commented Aug 28, 2021

Copy link
Copy Markdown

Not working on the front page at the moment version 1.4.0

@frbaroni

frbaroni commented Sep 7, 2021

Copy link
Copy Markdown

Not working on the front page at the moment version 1.4.0

In order to make it work on homepage we need to include a new tagName to the filtering list:

change:
while( tagName !== 'ytd-grid-video-renderer' && tagName !== 'ytd-item-section-renderer' );

to:
while( tagName !== 'ytd-grid-video-renderer' && tagName !== 'ytd-item-section-renderer' && tagName !== 'ytd-rich-item-renderer' );

or get it at my fork https://gist.github.com/frbaroni/7652d14f265ef67e37652d25206369ab

@Osahashi

Osahashi commented Sep 7, 2021

Copy link
Copy Markdown

Not working on the front page at the moment version 1.4.0

In order to make it work on homepage we need to include a new tagName to the filtering list:

change:
while( tagName !== 'ytd-grid-video-renderer' && tagName !== 'ytd-item-section-renderer' );

to:
while( tagName !== 'ytd-grid-video-renderer' && tagName !== 'ytd-item-section-renderer' && tagName !== 'ytd-rich-item-renderer' );

or get it at my fork https://gist.github.com/frbaroni/7652d14f265ef67e37652d25206369ab

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment