Skip to content

Instantly share code, notes, and snippets.

@Glench
Last active October 10, 2021 19:08
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 Glench/d0e85455d43901440630a899f298e202 to your computer and use it in GitHub Desktop.
Save Glench/d0e85455d43901440630a899f298e202 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Filter Youtube Homepage by Age
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Remove Youtube videos from homepage that are over x years old
// @author @Glench
// @match https://www.youtube.com/
// @icon https://www.google.com/s2/favicons?domain=youtube.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
var videos = document.querySelectorAll('ytd-rich-item-renderer');
for (var i=0; i < videos.length; ++i) {
var video = videos[i];
var metaBlocks = video.querySelectorAll('span.ytd-video-meta-block');
for (var j=0; j < metaBlocks.length; ++j) {
var metaBlock = metaBlocks[j];
var text = metaBlock.innerText;
if (text.includes('year') && parseInt(text) > 2) {
video.remove();
break;
}
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment