Created
May 23, 2012 03:37
-
-
Save kylestev/2773128 to your computer and use it in GitHub Desktop.
Fiddler Netflix blocker using HostList class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Fiddler; | |
| class Handlers { | |
| static var nopeGif = "<img src=\"http://i.imgur.com/OLRXz.gif\" />"; | |
| static var blocked = "<html><head><title>Blocked</title></head><body><h2>Blocked</h2><p>Stop using all my bandwidth!!</p><br />" + nopeGif + "</body></html>"; | |
| static var hostList = new HostList("*.netflix.com,*.nflximg.com"); | |
| static function OnBeforeRequest(oSession: Session) { | |
| if (hostList.ContainsHost(oSession.hostname)) { | |
| oSession["ui-bold"] = "true"; | |
| oSession["ui-color"] = "blue"; | |
| oSession.oRequest.FailSession(403, "Blocked", blocked); | |
| } | |
| } | |
| } |
Author
There's a subtle bug here, although it doesn't matter in your particular case. You should either use:
if (hostList.ContainsHost(oSession.host))or
if (hostList.ContainsHostname(oSession.hostname))Otherwise, rules that are constrained to particular ports won't work properly.
Author
@ericlaw thanks! sorry I didn't see this until now. This was from back in high school when I was writing some sample rulesets to show the IT department what Fiddler could do for them.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't have anything against Netflix; heck I watch shows on there all the time. This is just a demonstration of the HostList class since I was unable to find any on the net and figured others could benefit.