How to block ads. I mean completely block all the advertisement on the Internet or a web browser

Each of us would like to block all the annoying advertisement on the Internet. I will prompt how to do it qualitatively.

The most I love internet is because it was created on the basis of freedom, everybody could choose what website to visit, what data is received and will be sent to the target host and everything is open.

In order to completely block all the ads, it is necessary to do it bit by bit:

Choose and make a list of all the domain names which spread ads

Open the Developer toolbar in the Firefox browser. Choose the Network tab and open the website which contains ads:

network-developer-toolbar

Now can be seen all the requests made by the browser to open certain website, among them are ads requests too. It is necessary to go carefully through this list and determine the domain names in the Request URL field in the Headers tab for all ads requests made by the browser:

request-header

In the image above is seen that googleads.g.doubleclick.net domain name should be blocked.

Then create a list containing all these ads domain names. Save this list to an external storage, this will save time for the future. This technique works for text, image, and video ads as well. Sometimes smart ads spreaders use proxy but it’s visible as well. Read Chrome Developer Guide for clearance.

Block these domain names by adding them to the hosts file

Every Linux, BSD, or Windows systems has the hosts file which allows to block any IP address or domain name. On linux or Unix-like systems hosts file are located here:

/etc/hosts

On Windows systems the hosts file are located here:

/Windows/System32/drivers/etc/hosts

Just add lines following this template to your hosts file to block the domain names from the list:

# Website
127.0.0.1 domainnameone.com
127.0.0.1 domainnametwo.com 
127.0.0.1 domainnamethree.com

As for instance, the part of the hosts file to block Google ads:

# Google
127.0.0.1 tpc.googlesyndication.com
127.0.0.1 googleads.g.doubleclick.net
127.0.0.1 pagead2.googlesyndication.com
127.0.0.1 cm.g.doubleclick.net
127.0.0.1 adclick.g.doubleclick.ne
127.0.0.1 creativecdn.com
127.0.0.1 01.creativecdn.com
127.0.0.1 ad.doubleclick.net
127.0.0.1 pubads.g.doubleclick.net
127.0.0.1 partner.googleadservices.com

Choose HTML DOM elements which show ads on websites you visit

As for instance, let’s block ads on the Google search page ;). Open https://www.google.com/, choose ads block, click Inspect Element:

block-google-ads

Now can be seen that ads are showing in the div which has id:

#tvcap

Block these DOM elements in your browser

It’s time to block found DOM elements using any browser style editor extension. I recommend Stylish, but any other will fit as wel. After installing Stylish, click Write new style and put this code there:

#taw #tvcap {
  display:none;
}

Use this guide for websites you visit and you will never see ads again.

P.S. Enjoy the Internet without ads.