Blocking BSNL Ad Injection
Any of the usual blockers - NoScript, ABP, uBlock - can block the ad, but since the ISP is piggybacking a legitimate page request to deliver their content, the blockers block the legitimate js request and end up crippling the page. HTTPS Everywhere will alleviate the problem, but until https is more widely adopted, the solution that has worked for me with Firefox is to use a redirect blocker.
Install Redirector. Works on Firefox, Chrome and Opera.2
Create a new redirect (by clicking on its icon, then on Edit Redirects. Or type about:addons in address bar, find Redirector in the list, click Preferences next to it).
Put these settings.
Description: BSNL Ad Block Example URL: http://126.96.36.199/dyn/bg/BSNL-FreeRoaming/index.js?policy=26&policyname=BSNL-FreeRoaming&time=1461310826&webServer=http://188.8.131.52&url=http%3A%2F%2Fexample.com%2Fjs%2Fexample.js Include Pattern: http://*/dyn/bg/*/index.js*url=* Redirect To: $4 Pattern Type: Wildcard
Click on Advanced options and select URL decode from the option box labeled Process Matches. Example Result should now show http://example.com/js/example.js
Select only Scripts in Apply To list and save.
##### Injection Mechanism
It serves an ad if the requesting browser can display it (pretty readable logic here which reveals other ways to not receive ads - like changing user agent to iphone/android or certain Opera versions) and then redirects to the originally requested url.
http://184.108.40.206/cgi-bin/redirect?url=http%3A%2F%2Fwhatmoji.com%2Fjs%2Fbootstrap.min.js ---- ##### Notes <a name="bsnl-note1"><sup>1</sup></a>
The injected script. When Airtel’s like shenanigans were publicised last year, the programmer who posted the script was served a Cease and Desist from the Israeli developer of the script. Crossing fingers now.
It’s also available for Firefox on Android, but unfortunately it’s config page is inaccessible there and I haven’t figured out how to apply the settings. It’s apparently easy to do the kind of redirect I need here with the new WebExtensions API, so I’m thinking of writing a specific extension for blocking BSNL ads.