views:

158

answers:

1

I've been using Fiddler for a few days now, extending CustomRules.js with my own logic. However, the file is becoming quite heavy (it's fairly heavy to begin with). I'm not very familiar with .NET or JScript, but I would like to be able to split CustomRules.js into several smaller files that I can just include into CustomRules.js. Is this possible?

I'm also finding a need to have some sort of persistent storage across requests. Is there a simple way to store values in CustomRules.js for use in later requests?

+1  A: 

There's no direct way to split the rules file out into other files (I should probably think about adding one). What you can do is compile .NET libraries and call them from the script file, as described here: http://www.fiddler2.com/Fiddler/dev/UsingCSharp.asp

I would be interested in learning more about your Rules, as a large rules file suggests that perhaps I could bake more useful functionality directly into Fiddler.

"Persistent storage across requests"-- what type of storage? If you simply add a JavaScript global variable to the FiddlerScript, it will be maintained across requests-- this is basically how most of the Rules menu options work, for instance. If rather than "across requests" you mean "across Fiddler startups/shutdowns" then you'd have to write code to store the values to a file or the registry.

EricLaw -MSFT-
Thanks Eric!The custom rules I've written allow me to modify the POST data before the request is sent and modify the response data before it hits the browser. I wasn't sure of regex and other string manipulation functions were available in other areas of Fiddler or how to implement it differently.It sounds like a global variable is what I'm looking for in terms of storage across requests. I tried what I thought was creating a global variable, but it didn't last between the requests. I wasn't able to store a value from one request and retrieve it in another. What is the syntax for this?
Kevin
inside class Handlers {, add something like public static var sUA: String = "Mystring";You can then modify the sUA value inside any of the functions. Keep in mind that Fiddler is multithreaded and your script will be running in many different threads in parallel. If you're writing complicated rules, you might consider using an IFiddlerExtension, which allows you to write all of your code in C# and more easily exploit the richness of the .NET framework. http://www.fiddler2.com/fiddler/dev/IFiddlerExtension.asp
EricLaw -MSFT-
FWIW, Fiddler 2.2.6.4+ support a new preferences system that allows for automatic persistence of settings. See http://fiddler.wikidot.com/prefs for info.
EricLaw -MSFT-