How do I block ads on YouTube?

blacklisting

#199

Thanks for this… I’m testing it as well… so far, no videos blocked, and very few ads getting through. I need to do more detective work on the ones slipping past the block.


#200

Thank you very much for the regex expression!
I also have a few ads which still get through.
I think I have found which domain names still cause these ads.

For example:
r2.sn-4g5edney.googlevideo.com
r2—sn-4g5edney.googlevideo.com
r1.sn-mn4vg5aa-5hnz.googlevideo.com
r1—sn-mn4vg5aa-5hnz.googlevideo.com

The first and third domain names are blocked with the previous regex. The second and fourth domain name (the ones with the tree dashes) still let some ads through.

Can someone create an regex for these domain names ?
Thanks in advance.


#201

r[0-9]+([-]{1,3}|.)sn-.+\.googlevideo\.com

Having trouble getting the video’s shown. Mostly black holes suck the video’s in and nothing visible is show.


#202

I tried a other (more specific) one I made but it has the same problem: it also blocks some video’s. But here it is:

r[0-9]*([-]{1,3}|.)sn-[a-z0-9]{8}\.googlevideo\.com

I think YouTube/Google thought of this. Unless someone discovers a more specific pattern in the subdomains that loads the ads.

This is a good tool to check your RegEx against the domains: https://regexr.com


#203

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


#204

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


I concatenated every BlockList I could find
#205

Great job but what is the lifetime of such list?


#206

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.


#207

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


#208

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.


#209

Please elaborate on this because to me the domain is googlevideos.com and belonging to Markmonitor. Sub-domains are not used in whois.


#210

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)


#211

Pi-hole only works with (sub) domains and smart people at Google serve the advertisements and video’s from the same domain with similar Sub-domains.

The only way is now filtering in the client self.


#212

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?


#213

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.


#214

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


#215

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


#216

I’m testing on LG TV with webOS


#217

Almost the 200th posting in this thread and the concluding is that Pi-hole is not the tool to beat Google in this whatever and how clever the regex are constructed.

Google will generate random like URL’s which are kept in their database. You can’t defeat that unless you know are ahead of them. That is not going to happen and then just change a parameter and you can start from the beginning.


#218

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)