How do I block ads on YouTube?

This is exactly it. Youtube was first to do this and it has worked very well for them to defend against DNS based ad blockers

I've read that there ABP seems to block YouTube ads but I've haven't tried and I probably won't. I'm not sure what they are using.

I use ublock origin.

I have added the lists from uBlock Origin into my PiHole, because they are open source and the lists are avail on github.
Not sure about ABP.

add-ons and applications like uBlock, and ABP use a slightly different technology to block ads. where pi-hole only looks at XXXYYY.com
applications like listed above are able to look at XXXYYY.com/ZZZ

Hi,

Can you give us the link to download list from uBlock Origin ?
Thanks.

Add each one separately.

5 Likes

It was fast :star_struck:
Thanks

You can hit the heart symbol on my post instead of typing Thanks. It's easier :slight_smile:

1 Like

Could you tell me how you added them? I'm too noob in this =(

So is this working?

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

1 Like

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
1 Like

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?

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.

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

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?

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

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.

1 Like

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

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