Tuesday, October 14, 2014

Hulu Ad Removal

    One fine October morning I decided to catch up on the latest episode of South Park.  Now that the show is exclusively on Hulu I pointed my browser at the ad riddled domain and off I went.  Now before I go any further allow me to say am not an ad nazi.  One a site such as twitch I will even go as far as to pause ad-block in order to help support the streamer.  Hulu on the other hand infuriates me.  The fact that I have to watch the same pile of ads on my paid account as anyone not logged in makes no sense to me. Anyways, allow me to get to the point.
    It was time to do what I do best, tinker.  I took this as a great opportunity to do something I had been meaning to for quite some time now.  Play with node.js.  I spent the next half hour or so reading up on node and threw together a proxy server.  A special thanks to Peteris Krumins.  His blog entry on node proxy servers was instrumental in this project.  I modified my code to display the url associated with every incoming request and connected.  I loaded up a Hulu video and watched my traffic for a minute.  The first point that became abundantly clear to me is that a very high percent of ads on the page did not come from Hulu's domain.  I added a line to my code ignoring requests coming from outside of Hulu's domain. Another round of testing.  At this point I was blocking all ads on the page but I was still getting ads in my videos a majority of the time.  I went back and looked though my request info on the console of my proxy server.  At this point I noticed that the ads that were playing were coming from a subdomain of Hulu.  I added a check to disregard all requests from the subdomain, restarted my server and ran another test.  Success!  I tested on both windows and mac in chrome and firefox with perfect ad removal.  When I am running though my proxy anytime an ad is about to play it instead quickly flashes the "we are having trouble loading this message from our sponsor" message and then continues to play your video.  The attempt at displaying the ad takes about half a second and then your back into your favorite episode of Castle.
    If you would like the source shoot me an email and we will talk.  I would normally post it here but, it is very easy to recreate and I am not a lawyer.  The last thing I want is Hulu calling me talking about loss of revenue.  At the risk of this getting some very rich people just as mad, here is a link that shows it working.


  Allow me to end with some feedback on detecting the type of ad blocking.  All you would need to do is implement a system that runs a script connecting to an external server.  If the script is able to connect continue to let the video play, otherwise stop the video.  There are many systems such as this you could use and many ways to get each solution accomplished.

  If you want to know more about me or you are looking for someone with my skill set my contact info can be found at atarimaster.us