Monday, September 8, 2014

Blocking in-video Ads - Youtube and Live streaming Part 3

You may want to glance through  Part1Part2 of this series, before proceeding here.

This post was long overdue and I am glad that I have found time and the desire to update my blog. The post is going to be about Editing /etc/hosts file in linux and Mac

Let us raise a question to set the tone for this post -
          Wonder how the ads are getting rendered on your page ?

Like you guessed, it is again a http call to a server.  Now what will happen if we block the calls to that server ?

This idea of blocking the calls to the ad-server is the idea behind common ad-block plugins. They tend to keep a black-list of URLs and which is why updating the plugin once in a while seems to be a good idea; with each plugin update, it is quite likely that the black-list for ad-servers is updated.

Eg: We can use the chrome devtools to identify the element through which the ads are getting displayed. (Please refer [2] on DevTools usage)

Using chrome developer tools, it is easy to find the hostname that is serving the ads.

Like I already pointed out in Part1Part2 of this series, the Adblock and Adblock plus Chrome extensions will help you in this regards.

Once we identify the ad-server, we can block all http calls to this server through our /etc/hosts file (refer [1]). This is a crude/hacky way of blocking ads, but effective. The ad-blocking plugins typically work within the browser sandbox and block these http calls, without touching the /etc/hosts file.

However, I don't understand completely how these plugins manage to block Youtube's in-video ads still.

Note: It is worth noting that Firefox, Safari and IE also provide such capabilities through their corresponding browser tool namely "Inspector" in Firefox and Safari, and "Developer Tools" in IE. 

Reference: