I'm writing a chrome extension intended to hide videos from specified channels on youtube.
The solution I'm using right now looks like this:
var previousRendererAmount = 0;
window.setInterval( function() {
var currentRendererAmount = $(removableRendererNameString).length;
// Check if renderer amount har changed since last time (If not, we don't need to run the removal script.)
if( currentRendererAmount != previousRendererAmount) {
previousRendererAmount = currentRendererAmount;
removeVideos();
}
}, 20);
Simply put it's run at intervals of 20 milliseconds and does a check to see if video thumbnails shown has changed. If it has it runs the removal script.
But what I really want to do is to remove them before they are displayed. Something like an event handler triggered when the DOM element(and it's children) is created. Is this possible?