How do I block ads on YouTube?

Is there a ELI5 guide to get all this working? i literally just go into the whole Pi Hole thing and would love to block youtube ads

I made a list for me that works. Still some Videos starts after the second try.

http://adblock.amroemischengutshof.de/youtube-ads-list.txt

Joerg

hey msatter, i dont know if the list works in other countries, i am from germany. if i look youtube i`ll put every advertise on my blacklist and then i copy my list to the file on the web. so i think it will block few things.

doesnt seem to work for me, i get alot of r6 r10 r5 leaks still

There is a solution, it involves dns resolution and whois checking for specific domain blocks.

e.g. when requesting dns resolution for *.googlevideo.com then retrieve domain record if domain does not equal alphabet inc. then block else allow

This may take a little extra scripting but it should be a sureshot.

Forgive me I have been trying to wrap my head around regex and not sure I understand it at all, but we know the ads are coming from the googlevideos.com domain, and the prefix starts with an r. I know the syntax is not correct but wouldnt the regex just be something like r*.googlvideos.com

Basically a wild card saying if that sucker starts with r toss it out. so something like
r*.googlevideos.com
r*.*.googlevideos.com ( for the double prefix)

So I have AdBlock Plus addon on my Browser and it kicks out all Youtube Ads, I tried taking its list and adding it to pihole thinking may work but it didnt, how are they blocking them in the addon?

The browser plugin works like a local proxy (that's why is isolated to the device and not network wide).
It looks for specific content (not only hostname) in the way the video/url is called.

Pi-hole is only a DNS resolver at it's roots.

1 Like

What do you think about this regex ^r+.\.googlevideo.com$ ? I see only YT logo for 5 sec (or this is lucky case?)

Try loading a video with the regex in place on your mobile device. Is the video loading or is the video black and not loading?

(Either on the youtube app or a mobile browser).

I'm testing on LG TV with webOS

I've been using this regex entry from @brattanek for a few days and haven't got any ads on YouTube yet.
^r+.\.googlevideo.com$ ?

Weird thing though, when looking at the query log, the addresses don't appear as pi-holed.

(Tested with Apple TV and an Android phone)

yeah ^r+.\.googlevideo.com$ didnt work, on my vizio I get the PPG ad still. (hands beer to @anon55913113 ;-P)

^r[^.]+.googlevideo.com$

Anyone have a Solution yet?

Ok so i validated that the following regex are able to match the required r patterns of google.video, however pihole doesnt seem to be blacklisting them, they are still being forwarded. can someone explain this?

here are the two regexs I made and I know they work:

(^r\d+\.+[a-z]+\-\w+\.)googlevideo\.com$ // for rXX.sn type pattern

(^r\d+\-+[a-z]+\-\w+\.)googlevideo\.com$ //for rXX--sn type pattern

could it be that there is something before the rXX that we are not seeing example some encoding charaters?

Sorry @pk198105 but it doesn't work here (netherlands), i use on my laptop chrome without any browserextension but the ad video's are not blocked at all.

Here's what I came up with:
^(r[0-9]+(-{3}|.).+.googlevideo.com)$

I am no pro at regex...
It matched the following domains:
r1---sn-hp57ynel.googlevideo.com
r4---sn-p5qlsndk.googlevideo.com
r12.sn-bvvbax-hn26.googlevideo.com
r1.sn-5hne6n7e.googlevideo.com

NOTE: See the very top of this page: some things will work, some will not. You're better off getting the fingerprints/definitions from the variations of the script(s) above and having it block the ads for you that way. Otherwise, it becomes to tedious to keep up with and is really hit-or-miss.

Best Regards,

Jayke P.

@jaykepeters, the regular video's are with your regex command blocked, in my case anyway.
When i delete your regex it works again

I'm sorry, I forgot to mention that it breaks YouTube for me too. I am experimenting with other ways to block YouTube ads using pi-hole.