Rahul Dharan

JavaScript's Own Boy

github twitter linkedin instagram email
How to Watch Ipl on Hotstar for Free With Only 2 Lines of Code
Mar 16, 2019
3 minutes read

Disclaimer: I do not advice anyone to use this to watch content on Hotstar for free, this is purely for educational purposes.

India Premier League can be streamed live on Hotstar, note that it’s a paid service. Here’s where Hotstar messed up, since Hotstar is so nice they allow you to watch a 10 minute preview without logging into the platform.

As soon as I noticed this, my spidey senses started to tingle. Being a JavaScript junkie, I knew they had to store something locally to keep the time in sync with the server. JavaScript has limited APIs to store data locally (Cookies, Local Storage etc.…) and these APIs are readily available to the users.

Now all I had to do was figure out what is stored to sync time with the server and then try modifying it, so that the timer resets, allowing me to watch the game indefinitely.

image of localstorage

Turns out this is the only value they use to sync time with the server, now all we have to do is clear this. Instead of clearing exactly one value, we will use generic code to clear everything from localStorage.

The code is pretty straight forward:

window.localStorage.clear();

But we have an issue, just running this won’t work because the website keeps sending requests to sync time with the server, by the time we run the script and reload the page, the page would have sent out multiple requests and synced with the server.

The solution is to run the code repetitively using setInterval.

setInterval(() => { window.localStorage.clear() }, 0);

Now all we have to do is reload the page for it to take action. Since Hotstar allows you to watch a preview of 10 mins we can reload the tab at the 9th minute.

setInterval(() => { window.localStorage.clear() }, 0);
setTimeout(() => { window.location.reload() }, 540000);
  • *540000 is 9 minutes in milliseconds.

voilà we are done, this is all it takes to beat the system.

You might have noticed there was some manual intervention required, so I wrote a chrome extension to inject the above mentioned code into the target page.

Let’s set up the manifest.json file for the chrome extension with the following permissions.

...
"permissions": [
  "tabs",
  "activeTab"
]
...

All we have to do is listen to two events: 1. Extension icon click event (chrome.browserAction.onClicked) 2. Page reload event (chrome.tabs.onUpdated)

When the user clicks on the extension, it means he/she wants to inject the code into the active tab.

After about 9 minutes when the page reloads we listen to reload event and inject the code into the active tab. This keeps repeating, giving us a perfect loop, every 9 minutes the page reloads and on reload the script is injected again resetting the timer.

The code is available on github( view ).

EDIT: Hotstar reduced the freemium time from 10 minutes to 5 minutes, we can fix this by changing the code to -

setInterval(() => { window.localStorage.clear() }, 0);
setTimeout(() => { window.location.reload() }, 180000);
  • 180000 is 3 minutes in milliseconds.

Where do I input this code you ask?

Open any broswer and open the hotstar tab, then right click on the screen select inspect option, now click on the console tab. Enter the code here.


Back to posts


comments powered by Disqus