The following script used to hide YouTube videos based on their age but it doesn't work anymore - and I can't figure out how to fix it. Can anyone help or create a similar script?
(function() { 'use strict';
function Hide() { //Starts the function
var videos = document.querySelectorAll("#contents > .ytd-rich-grid-renderer"); for (var i = videos.length; i--;) { //For every video on the page
var ageChild = videos[i].querySelector("#metadata-line > span:nth-child(2)"); //Find metadata line containing age of video
if (ageChild !== null) { if ( (ageChild.innerText.match('year') !== null) || (ageChild.innerText.match('month') !== null) || (ageChild.innerText.match('week') !== null) ) { //If the video is older than a week, month, or year videos[i].style.display = 'none'; //Hide the video } //Finishes the if condition }
var mixChild = videos[i].querySelector("#video-title"); //Find video title
if (mixChild !== null) { if ( (mixChild.innerText.match('Mix') !== null) ) { //If the video is a mix playlist videos[i].style.display = 'none'; //Hide the mix playlist } //Finishes the if condition }
} //Finishes the for condition
} //Finishes the function
Hide(); //Run the function to hide videos when the youtube dashboard is loaded
setTimeout(function(){ Hide() //Run the function to hide videos again 2 seconds after loading in case youtube hasn't finished loading yet... }, 2000);
window.onscroll = async function() { //Every time that the page it scrolled Hide(); //Look for old videos or mixes and hide them }; //Finishes the onscroll advent listener
The following script used to hide YouTube videos based on their age but it doesn't work anymore - and I can't figure out how to fix it.
Can anyone help or create a similar script?
(function() {
'use strict';
function Hide() { //Starts the function
var videos = document.querySelectorAll("#contents > .ytd-rich-grid-renderer");
for (var i = videos.length; i--;) { //For every video on the page
var ageChild = videos[i].querySelector("#metadata-line > span:nth-child(2)"); //Find metadata line containing age of video
if (ageChild !== null) {
if ( (ageChild.innerText.match('year') !== null) || (ageChild.innerText.match('month') !== null) || (ageChild.innerText.match('week') !== null) ) { //If the video is older than a week, month, or year
videos[i].style.display = 'none'; //Hide the video
} //Finishes the if condition
}
var mixChild = videos[i].querySelector("#video-title"); //Find video title
if (mixChild !== null) {
if ( (mixChild.innerText.match('Mix') !== null) ) { //If the video is a mix playlist
videos[i].style.display = 'none'; //Hide the mix playlist
} //Finishes the if condition
}
} //Finishes the for condition
} //Finishes the function
Hide(); //Run the function to hide videos when the youtube dashboard is loaded
setTimeout(function(){
Hide() //Run the function to hide videos again 2 seconds after loading in case youtube hasn't finished loading yet...
}, 2000);
window.onscroll = async function() { //Every time that the page it scrolled
Hide(); //Look for old videos or mixes and hide them
}; //Finishes the onscroll advent listener
})();