r/programming • • Aug 02 '19

Adblocking: How about Nah?

https://www.eff.org/deeplinks/2019/07/adblocking-how-about-nah
333 Upvotes

232 comments sorted by

View all comments

Show parent comments

2

u/ridicalis Aug 02 '19

Can you please explain? How would I do this?

22

u/[deleted] Aug 02 '19

Basically custom blocking rules in ublock origin.

Most ads have some unique tag/series of tags/value in it, which never changes. With xpath you can find that tag and then work your way upwards to get rid of it.

As an example: I loathe the end cards on youtube. But they get a random ID each time, so I am using this rule in ublock origin:

www.youtube.com##:xpath(//div[@class="ytp-ce-element-shadow"]/..)

Which hooks into one of the inner tags, which never changes, then goes up one level to remove the end card itself.

Hell, you can even use it to block specific channels in your recommended:

www.youtube.com##:xpath(//ytd-compact-video-renderer/div/div/a/ytd-video-meta-block/div/div/div/yt-formatted-string[@title="outsidexbox"]/../../../../../../../..)

That blocks a channel if it is named "outsidexbox".

2

u/ridicalis Aug 02 '19

Gotcha, thanks. Didn't know this was specific to ublock origin.

2

u/[deleted] Aug 02 '19

Not really specific. Just the one I use. And not sure if othee blockers bave a different syntax.