Remove reddit's livestream with browser extension, what event to track content loading?

Viewed 86

As many of us do, I too have a reddit tab open while working to scroll occasionally I don't really like skipping content that I did not choose to see and I'm talking about that Reddit's livestream feed garbage full of cats and improvised musicians.

Long story short, since I couldn't find it online I decided to make the supidest extension to remove'em from my feed.

It is literally two lines of code to check the class and remove the node but I couldn't find how to track the loading of new content beause I refuse to use a timer to check if it exists.

Here's the code:

var liveList = document.querySelectorAll('div[data-testid="post-container"]:not(.Post)')
liveList.forEach((e) => {e.remove()})

I tried with the MutationObserver class but no results, I don't have much experience with js, so I'm asking you all for some help on how to do it

1 Answers

Perhaps the chrome.webRequest API.

You can use your browser's devtools to observe network traffic as you navigate, and try to figure out what the request for a livestream looks like. If it is somehow identifiable, you could simply register for all requests, and run your code to remove the appropriate node if the web request matches that of a livestream.

Related