0

I want to filter out nonsense recommendation from YouTube using channel's name.

Currently I use something along the line of

grids = document.getElementsByTagName("ytm-rich-item-renderer");
grid_inner = grid.innerText.split('\n');
grid_inner_info = grid_inner[grid_inner.length - 1].split("•");
channel = grid_inner_info[0];
for (var i = 0; i < grids.length; i++) { 
    grid = grids[i];
    if (!channels.includes(channel)) grid.remove();
}

However the recommended videos showed up first then got removed, which interrupt scrolling in the mobile (Firefox Nightly).

If I want to remove videos based on the title instead, I can do this in uBlock

youtube.com##ytd-rich-item-renderer:has-text(/Man Utd/)

And these things will never show up in the first place.

My question is, how does uBlock remove elements before it render?

Natthaphon Hongcharoen
  • 2,032
  • 1
  • 7
  • 17
  • 1
    See [Deleting DOM elements before the Page is displayed to the screen (in a Chrome extension)](https://stackoverflow.com/a/32537455) and [How to detect page navigation on YouTube and modify its appearance seamlessly?](https://stackoverflow.com/a/34100952) – wOxxOm Apr 15 '22 at 12:07
  • Thanks, I'll see what I can do with those – Natthaphon Hongcharoen Apr 15 '22 at 12:24

0 Answers0