How do I block ads on YouTube?

blacklisting

#177

So is this working?


#178

The script works, but the result doesn’t. In other words blocks legit videos and you are going to still watch ads.


#180

I followed SoNic67’s advice in the previous post and added the uBlock Origin’s uAssets, and I haven’t seen any YouTube ads on my devices since!

For those curious, I added the following URLs into Settings > Block Lists:

https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/annoyances.txt
https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/badware.txt
https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/experimental.txt
https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/filters.txt
https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/privacy.txt
https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/resource-abuse.txt
https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/resources.txt
https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/unbreak.txt

#181

Did the adding of ublock origin filters in my Settings > Block Lists but the number of domains blacklisted didn’t increase in my dashboard. Is there something else I should do?


#182

Make sure you select “save and update” on the block list screen. If you just “save” it won’t update all the lists.

Or, from the Pi terminal, run pihole -g to update the gravity list.


#183
> [i] Neutrino emissions detected...
>   [✓] Pulling blocklist source list into range
> 
>   [i] Target: raw.githubusercontent.com (hosts)
>   [✓] Status: Retrieval successful
> 
>   [i] Target: mirror1.malwaredomains.com (justdomains)
>   [✓] Status: No changes detected
> 
>   [i] Target: sysctl.org (hosts)
>   [✓] Status: No changes detected
> 
>   [i] Target: zeustracker.abuse.ch (blocklist.php?download=domainblocklist)
>   [✓] Status: No changes detected
> 
>   [i] Target: s3.amazonaws.com (simple_tracking.txt)
>   [✓] Status: No changes detected
> 
>   [i] Target: s3.amazonaws.com (simple_ad.txt)
>   [✓] Status: No changes detected
> 
>   [i] Target: hosts-file.net (ad_servers.txt)
>   [✓] Status: No changes detected
> 
>   [i] Target: raw.githubusercontent.com (annoyances.txt)
>   [✓] Status: Retrieval successful
>   [i] Format: Adblockcomm: file 1 is not in sorted order
>   [✓] Format: Adblock
> 
>   [i] Target: raw.githubusercontent.com (badware.txt)
>   [✓] Status: Retrieval successful
>   [✓] Format: Adblock
> 
>   [i] Target: raw.githubusercontent.com (experimental.txt)
>   [✓] Status: Retrieval successful
>   [✓] Format: Adblock
> 
>   [i] Target: raw.githubusercontent.com (filters.txt)
>   [✓] Status: Retrieval successful
>   [i] Format: Adblockcomm: file 1 is not in sorted order
>   [✓] Format: Adblock
> 
>   [i] Target: raw.githubusercontent.com (privacy.txt)
>   [✓] Status: Retrieval successful
>   [✓] Format: Adblock
> 
>   [i] Target: raw.githubusercontent.com (resource-abuse.txt)
>   [✓] Status: Retrieval successful
>   [✓] Format: Adblock
> 
>   [i] Target: raw.githubusercontent.com (resources.txt)
>   [✓] Status: Retrieval successful
> 
>   [i] Target: raw.githubusercontent.com (unbreak.txt)
>   [✓] Status: Retrieval successful
>   [i] Format: Adblockcomm: file 1 is not in sorted order
>   [✓] Format: Adblock
> 
>   [✓] Consolidating blocklists
>   [✓] Extracting domains from blocklists
>   [i] Number of domains being pulled in by gravity: 155602
>   [✓] Removing duplicate domains
>   [i] Number of unique domains trapped in the Event Horizon: 132116
>   [i] Nothing to whitelist!
>   [✓] Parsing domains into hosts format
>   [✓] Cleaning up stray matter
> 
>   [✓] Force-reloading DNS service
>   [✓] DNS service is running
>   [✓] Pi-hole blocking is Enabled

this is the output when I ran pihole -g, but the number of domains blocked didn’t go up. It’s still in 132K domains which was the same number before I added the ublock origin filters.


#185

these are the lists in /etc/pihole

>  16:43 adlists.list
>  16:46 GitHubVersions
>  16:55 gravity.list
>  14:06 install.log
>  16:55 list.0.raw.githubusercontent.com.domains
>  16:55 list.10.raw.githubusercontent.com.domains
>  16:55 list.11.raw.githubusercontent.com.domains
>  16:55 list.12.raw.githubusercontent.com.domains
>  16:55 list.13.raw.githubusercontent.com.domains
>  16:55 list.14.raw.githubusercontent.com.domains
>  14:06 list.1.mirror1.malwaredomains.com.domains
>  14:06 list.2.sysctl.org.domains
>  14:06 list.3.zeustracker.abuse.ch.domains
>  14:06 list.4.s3.amazonaws.com.domains
>  14:06 list.5.s3.amazonaws.com.domains
>  14:07 list.6.hosts-file.net.domains
>  16:55 list.7.raw.githubusercontent.com.domains
>  16:55 list.8.raw.githubusercontent.com.domains
>  16:55 list.9.raw.githubusercontent.com.domains
>  16:55 list.preEventHorizon
>  17:30 localbranches
>  16:55 local.list
>  17:30 localversions
>  14:06 logrotate
>  17:32 pihole-FTL.db
>  14:06 setupVars.conf

does this mean that the pihole has successfully added the ublock filters eventhough my domains on blocklists have not increased?


#186

It doesn’t look like any loaded. Doing some thinking and I’ll get back to you.


#187

How is “dummy.com##blablabla” handled?

Pi-hole has to keep the domain but remove ##blablabla, so is that the case it should be added to the gravity.list


#188

Those files are not supported by Pi-hole.

Pi-hole uses host like format for it’s adlists.

I think the user above that reported no ads, either used it on his client (via a browser plugin) or it was a pure coincidence that he didn’t get any ads.

The files above (with the exception of a few entries here and there that actually mess up gravity), are useless (and ignored) in Pi-hole.


#189

Here’s a related post on the topic of block list formats: How do I add additional block lists to Pi-hole?


#190

Awk -F splits on given IFS, we grab the right hand side (chops trailing #coments and /'s to grab the domain only.

Good: echo dummy.com##blablabla | awk -F '#' '{print $1}' --> dummy.com

So the domains should be added if they were not already in other lists.


#191

Hi all,
So, did someone found a pattern to block youtube ads?
Once the pattern is found it’s easy to catch with regex (no need for scripts etc.).

I guess this is impossible, I checked domains which provides videos and those who provide ads, there are the same, no difference, no pattern to discriminate both. It seems that all domains are generated randomly.
Maybe Adblock extension creators have an idea about it…


#192

So, do any of these methods/scripts currently work? I have read through this thread and I am not really sure which of the above solutions actually work or are suggested. I am just wondering if one of the above solutions works. If so, which?


#193

Not really. They (the ads) are self hosted so it’s hard to block them at DNS level.

The scripts above DO work on PC but they break Mobile apps (like Youtube and Youtube Music).

However, regex is available in the new version of Pi-hole and that’s a path worth looking into …


#194

check my script for blocking the sites:


#195

Should Regex blocking with this string work correctly?

^r[0-9]+*sn-*\.googlevideo\.com$


#196

You can check your expressions here: https://regexper.com.

Yours throws an error there.


#197

Yes it would block the advertisements but also the videos itself. This if I remember it correct from my last try.


YouTube plays ads on my nVidia Shield, like Pi-Hole never existed
#198

Thanks, I’m testing the following now, it doesn’t block video (yet?):
r[0-9]+.sn-.\.googlevideo\.com

UPDATE: I had a working one that also blocks video… they are not that stupid