Blocking ads on Facebook (and Google, soon)
The longer version:
I’m not a big fan of ads on the websites (I’m OK with innovative ads on YouTube though), especially on Facebook as these ads are disguising themselves as a post in my feed. What to do? Using Adblock? Nah, at least as of the moment since Adblock cannot easily detect Facebook ads.
- Locate the divs containing the ads: currently, it is under div.userContentWrapper and having the text such as “Sponsored“, “Suggested Post“, “Chartered“
- Add a MutationObserver to the HTML body, upon detection of body elements changed, look for these ads and remove them from the DOM tree.
It was short and simple. I’m going to take this approach to write Google Ads block script. Hang on tight.
2017-03-20 / Dio Phung / 0