How do I block ads on YouTube?

Where is the source coming from?
maybe pihole or firewall use filter all dns.google or dns.google.com

From my tests the BIG problem is that G. API will not switch back to DNS servers defined by DHCP server if I block on firewall all G. DNS servers over HTTPS.
You block Google DNS servers over HTTPS you can't watch youtube, can't use G maps, or G translate... so good luck blocking google ads.
Why do you think Google/Alphabet support and developed DNS over HTTPS ?
For privacy ? Let's be serious, it is only for profit.

1 Like

Your remark is interesting, since Wednesday pi-hole can't catch DNS request from my iPad (Youtube application) but works with my iPhone and I tried to understand why.

What it means exactly : on a device X, Youtube application uses DHCP server by default but switches definitely on DNS over HTTPS for this device X if it has trouble to get response with the DHCP?

IMO the best way to block ads in YouTube is by avoiding it completely :wink:

I suggest using https://invidio.us/ instead. Invidious is an open-source front-end for YouTube. It works without javascript enabled (unless you want to see the comments for each video) and you won't see any ads.

By default, you'll see network requests to googlevideo.com. However, even this can be avoided by checking the "Proxy videos?" option in the settings in the upper right corner.

Note that there are several Invidious instances available which might be more performant than invidio.us.

The best way to use it, IMO, is by installing the Invidition add-on for Firefox which redirects all requests to YouTube (even in embedded videos on other sites) to invidio.us (or, alternatively, to one of the other instances). You can check the option "Force proxy" to avoid googlevideo.com.

Result: a Google-free YouTube :smile:

Note: If you're using uMatrix or Noscript you might want to add the appropriate rulesets for those add-ons available on the Invidition homepage.

1 Like

[quote="pi-user, post:364, topic:253, full:true"]I suggest using https://invidio.us/ instead.
[/quote]

Doesn't work with smart TVs.

Yes, that's a problem for sure. Perhaps there is a solution similar to what is discussed here.

Thank you so much for the answers worked for me

In this thread I see some scripts generating blacklists.
but if you do that, You might just as well add the following regex

((^)|(\.))googlevideo\.

It probably is faster as your name server doesn't have to crawl through all the results.
for normal videos, YouTube will fall back to another domain.
but if there is a commercial, you cannot see it but have to refresh to show the page.
that isn't really a solution.

for some reason my add blocker is able to determine and exclude YouTube commercials. Of course my add-blocker has more information then only the host name, I has access to actual content.

Assuming mobile apps use the same host names as the webapplication.
We can create an online list with host names to block.
and a webservice where urls can be submitted.
then create an add on for Firefox and Chrome which detects the urls with youtube commercials and if one is detected it should be submitted to the webapi.

It is a lot of work, no doubt about that, also to prevent people from adding other domains manually.
But I think it is doable.
The more people who use this add on the more accurate the block will be.

anyone any thoughts on this, also it would be helpfull if someone would know if the host urls for YouTube apps would be the same as for the webversion.

Edit:
Ok, forget what I said before, it's just not going to work, I checked what my add blocker does. Different from blocking complete domains, it blocks this script

https://www.youtube.com/get_midroll_info?ei=8QQAXa.........

which cannot be blocked simply by host,
I checked to scripts, and found a suspicious domain "v3m.uuzu.com" not sure wat is does, but I added it to the blacklist just to be sure,it doesn't help at all.

Hi
I have a similar problem to yours, I have installed your ads-catcher, it seems like working (fewer ads) from all of my devices except my iPad (don't know why).

I can only see that in the log file:
[2019. jún. 25., kedd, 19:29:23 CEST] ads-catcher-blacklister
[i] Adding r3---sn-po8puxa-c0qs.googlevideo.com to blacklist...
[i] r3---sn-po8puxa-c0qs.googlevideo.com does not exist in whitelist, no need to remove!
[i] r4---sn-po8puxa-c0qs.googlevideo.com already exists in blacklist, no need to add!
[i] r4---sn-po8puxa-c0qs.googlevideo.com does not exist in whitelist, no need to remove!

[i] Pi-hole blocking is enabled
[i] Using cached Event Horizon list...
[i] 114874 unique domains trapped in the Event Horizon
[i] Number of blacklisted domains: 123
[i] Number of regex filters: 1
[✓] Parsing domains into hosts format
[✓] Cleaning up stray matter

[✓] DNS service is running
[✓] Pi-hole blocking is Enabled

Maybe you can explain, or have solution to that.
Thanks in advance!

Bence

hi guys
On the topic "ads in Youtube" ...
For my part I work with the following regex in the blacklist.
grafik
I am satisfied with the result. This regex does not filter every advertisement, but still a lot.
Just give it a try ... :slight_smile:

EDIT: 12.07.2019
Regex inserted as image because the regex was misrepresented by HTML display.

Last time I tried blocking ads for YouTube, videos weren't loading :frowning: I had to refresh the page multiple times to get a video.

I've added the regex above you and I can still play videos on pc and mobile. Ads still coming in though.

Would you say you have less ads? I would like to remove uBlock as some websites are angry at me now :stuck_out_tongue: But I hate 2 full ads before a video too so...

i'm new to this world, would you please tell me how to install this script on pi-hole ? thanks

Which script are you referring to?

GitHub - kboghdady/youTube_ads_4_pi-hole: YouTube script to add the new Ads list for Pi-hole this one

Hello

Here is my opinion on this topic...

  1. It makes no sense to collect all links from Youtube videos and put them in a blocklist.
    Reason: There is - in my opinion - no clear differentiation between "good" and "bad" links. This means that every link is able to deliver advertising. Sooner or later, this will probably mean that most video links will end up on the blacklist and than no or only a few videos will be displayed.

  2. I also found out that it makes a difference which country you've just connected to Youtube. Also, the DNS servers used seem to somehow have an influence on which and how much advertising gets presented.

For my part, I have come to terms with it and live by the fact that once more or less advertising is displayed. My regex (from above) fulfills its purpose for me. This blocked video links, which are based on the pattern "sn-xxxxxxx-xxxx.googlevideo.com".

so long ...
Speedy70

please excuse my english ... i had to try the google translator :slight_smile:

1 Like

I'm using the script from GitHub - kboghdady/youTube_ads_4_pi-hole: YouTube script to add the new Ads list for Pi-hole
I run the cron job every 5 mins.
I am having no luck at all playing videos when I use a Wired connection unless I disable the Pihole.
The Wired connection's static IP is showing in the blacklist I am unsure why.

I have been using the script for a while and I have videos that wont start unless I disable the pihole.

blacklist.txt Its refreshed every 15 seconds via cron job
http://wagnwashcloud.dogrusoz.net/index.php/s/pekrxZoY3BSia2c/download

.*sn-\S{4,}-\S{4,}\.googlevideo\.com

screenshot
youtube-regex
I've added the above regex. (Hope it's correct)

My youtube domains is tailing out these. I've checked with a regex checker and it's not catching it. Different because of region location?

r1---sn-ogul7n7z.googlevideo.com
r1---sn-ogul7n7z.googlevideo.com
r3---sn-oguesnze.googlevideo.com
r3---sn-oguesnze.googlevideo.com
r3---sn-ogul7n7z.googlevideo.com
r3---sn-oguesnzd.googlevideo.com
r3---sn-oguesnzd.googlevideo.com
r4---sn-ogueln7y.googlevideo.com

Hello @duceduc

Your regex
grafik
and blocking result are perfectly fine that way. The regex does exactly what it was built for. Namely, find domains that have a very specific structure.
please refer:
grafik

The reason why I built the regex is that - at least for me - a lot of advertising come from domains, which have exactly this structure. As stated above, it is almost impossible to get the advertising on Youtube using Regex under control. The only thing that currently helps against this type of advertising is a browser extension (AddBlocker).

greeting
Speedy70