leksar / NewTube (removing old videos) RU

// ==UserScript==
// @name         NewTube (removing old videos) RU
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  removes youtube(RU) videos older than 1 year
// @author       Alex Leksar
// @match        https://www.youtube.com/
// @grant        none
// @licence MIT
// ==/UserScript==

(function() {
    function removeOldVideos() {
    let entities = document.querySelectorAll("span.ytd-grid-video-renderer");

    entities.forEach(el => {
        if (el.innerText && (el.innerText.includes('год') || el.innerText.includes('лет'))) el.closest('ytd-grid-video-renderer').style.display = 'none';
    })
}

let debounceTimer;
function scrollFunction() {
    clearTimeout(debounceTimer)
    debounceTimer = setTimeout(() => removeOldVideos(), 500)
}

window.onscroll = scrollFunction;
    removeOldVideos();
})();