Skip to content

Instantly share code, notes, and snippets.

@assertchris
Created September 3, 2022 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save assertchris/b9c57016841a7c9997c6b2a2eccb62d8 to your computer and use it in GitHub Desktop.
Save assertchris/b9c57016841a7c9997c6b2a2eccb62d8 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Hide already watched YouTube videos
// @version 0.1
// @description Hide already watched recommended YouTube videos from the home page
// @match https://www.youtube.com
// ==/UserScript==
(function() {
'use strict';
(function() {
'use strict';
var found;
var interval = setInterval(function() {
var recommendation = document.querySelector('ytd-thumbnail-overlay-resume-playback-renderer [style="width: 100%;"]:not([clicked])');
if (!recommendation) {
return;
}
var button = recommendation.parentNode?.parentNode?.parentNode?.parentNode?.parentNode?.querySelector('[aria-label="Action menu"]');
if (!button) {
return;
}
recommendation.setAttribute('clicked', 'clicked');
button.click();
setTimeout(function() {
document.querySelectorAll('[role="menuitem"]')[4].click();
}, 250);
}, 500);
})();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment