[General Topics] chocolote4444:
Welcome Android users!

As we all know, ads are extremely annoying. It seems like there are more ads than ever in today's Internet world.

Today I will not only show you how to block ads in the official YouTube app, but will also TEACH you how to find their ad domains using an SSL packet capture technique, that way you can find all the ad domains, and block them.

We all know that developers need ads to make income. Having ads will help support developers. But some put too many ads which can be annoying. Don't do this if you support ads. However, If you really don't like ads at all, this tutorial is for you.

The official YouTube app would be the perfect example. Yes, the ads in YouTube has gotten out of control. But remember that this is just an opinion. You do not have to agree with my opinions. I don't mind some ads, but if there is a video ad at EVERY video I watch, that annoys me. You may heard of an app called "Adaway". Most root users probably use adaway to try to block YouTube's ads but after looking at some of the threads on XDA, I am beginning to notice that adaway isn't blocking ALL of YouTube's ads, and that people are still seeing ads. So instead, we are going to actually FIND the ads, and block them by modifying the "hosts" file.

Requirements:

Android Phone that is rooted (BusyBox is recommended!!)

Sift - SSL Security & Firewall App (It's on the Play Store!!!!)

A root browser (Doesn't matter what root browser!)

Hosts Editor (Also on the Play Store!)

Blocking ads using the hosts technique is nothing new. People have been using this technique to block ads for a long time. But how exactly do those people find these "hosts"?

Just like with Windows, Android has a hosts file. It is located in the directory /system/etc/hosts

The hosts file basically maps hosts names to I.P. addresses. If you open it up with your root browser, you will see this line of text : View attachment 4017875

127.0.0.1 localhost

That is your original local host. To block a server or a domain, we will simply add a host name. For example, if I wanted to block www.google.com, I would simply add this to the hosts file:

127.0.0.1 localhost

127.0.0.1 www.google.com

Of course you need a root bowser with superuser privileges to do this. Now try going to www.google.com on your browser. It won't load. That's because you blocked the domain.

That is basically how you block a domain. So let's get started with blocking YouTube's ads.

1. Open up Sift - SSL Security and Firewall and tap on the button on the bottom right. It will ask for your permission to set up a VPN connection. Tap "ok" and it will start running.

Now everything will go through Sift's Firewall and will be captured. Go ahead and open the YouTube app.

2. Just start watching videos until a video ad appears and let it play. Sift will capture that video ad :good:

3. Now go ahead and exit the YouTube app and open up Sift. Go ahead and disconnect from the VPN. Tap on Youtube and you SHOULD see all these kinds of servers like:

View attachment 4017888

Now which servers do you think are the ad servers? Obviously ad.doubleclick.net is one of them. That is a no-brainer. Now all we have to do is add "ad.doubleclick.net" and all the other ad servers that we captured to the hosts file.

4. To make it easier, use Hosts Editor by opening up the app and clicking on the plus button. Add it to the hosts. Should look like this:

View attachment 4017896

Then tap "Add Hostname" .

Congratulations! You have successfully blocked your FIRST ad DNS domain!

Obviously there are more. You might see these ad servers as well:

securepubads.g.doubleclick.net

suggestqueries.google.com

redirector.googlevideo.com

and much more!!

WARNING!!!!!!!!!!!!!!

Don't block EVERY hosts you see that is captured in Sift!!! You OBVIOUSLY don't want to block www.youtube.com. To help you root users, here are the domains that you do NOT want to block:

youtubei.googleapis.com

i.ytimg.com

android.clients.google.com

yt3.ggpht.com

Sometimes you might come across a weird domain like r5---sn-q4f7snel.googlevideo.com.

I haven't been able to officially determine if those are ad servers. YouTube has ALOT of ad domains. I believe different YouTube channels use different ad domains. But I haven't been able to determine this out yet. If you are still seeing video ads, keep adding host names until you don't see any ads.

For a good start, I added a modified "hosts" file to help get you started. Download it below and overwrite your hosts file. Make sure to make a backup if anything goes wrong!! Make sure you set the correct attributes (Permissions) to -rw-r--r- also, remove .txt extension.

View attachment 4017946

View attachment 4017921

You can also try this method with other apps too!

I really hope this helps everyone who doesn't like ads. Please leave any comments or suggestions that you may have!

I have been posting a lot recently on XDA so I will take a break. If you have any questions, It might take me a while to reply.