Last active
October 10, 2021 19:08
-
-
Save Glench/d0e85455d43901440630a899f298e202 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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