How to prevent YouTube from showing already watched videos?

Is there a way to prevent YouTube from showing videos already watched in the list of suggested videos?

Answer

Currently, there is no treat/workaround to do so. Apart from manually block them one by one, there are no scalable solutions.

0

But there are extensions which can do so like:


// ==UserScript==
// @version        1.1.1
// @name           Hide watched videos on YouTube
// @namespace      https://gist.github.com/xPaw/6324624
// @match          https://www.youtube.com/*
// @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-thumbnail-overlay-resume-playback-renderer:not([data-hidden="true"])' ).forEach( element =>
    {
        element.dataset.hidden = true;

        while( ( element = element.parentNode ).tagName.toLowerCase() !== 'ytd-item-section-renderer' )
        {
            // Find the container element for this video
        }

        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 } );
}

app.addEventListener( 'yt-navigate-finish', ProcessPage );

ProcessPage();

Attribution
Source : Link , Question Author : E. Sommer , Answer Author : user0

Leave a Comment