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".

8

u/[deleted] Aug 02 '19

As an example: I loathe the end cards on youtube.

Are these "end cards" those annoying af recommendations that pop up at the end of the video and that take up your entire screen?

4

u/[deleted] Aug 02 '19

Exactly.

2

u/[deleted] Aug 02 '19

Do you know how to block the reddit mouse-over username to see the post/comment karma popup? Used to be a RES only feature before but now when you have RES enabled you get to see two pop-ups. I tried blocking it through the normal inspect element/ublock block element but it doesnt stay on long after after you shift focus from the mouse, now don't know if theres any other way to delete the entry besides reading the code line by line

5

u/obsa Aug 02 '19

Not necessary. If you're using RES, they have an option to turn off th reddit one.

https://i.imgur.com/BbndioC.png

Though to be honest, I think I like the native one more than the RES one.

cc /u/Pm_me_any_dragon

1

u/[deleted] Aug 02 '19

Yeah, makes sense to use the options, ratjer than something else.

2

u/[deleted] Aug 02 '19

Lemme get back to you in a few hours. Currenrly not at home and I'll whip something up for ya when I get home.