Fiddler 2.3 will include a new preferences management system which is accessible to script and extensions. The system will be somewhat similar to the preferences system within Firefox (e.g. type about:config in Firefox to view the preferences).
Overview
- The Preference values are automatically serialized to and deserialized from the registry. (Note: See the "Magic Names" section below).
Preference Naming
- Preference names are not case-sensitive.
- Preference names must contain ASCII A-Z, numbers, dots, and dashes only.
- Preference names must be between 1 and 255 characters in length.
- Prefs containing the word ephemeral will not be saved or loaded from the registry
- Prefs containing the word internal cannot be created or updated by extensions or script
The current preferences list is here
The IFiddlerPreferences Interface
Fiddler's Preference object will be found at FiddlerApplication.Prefs; it exposes the IFiddlerPreferences interface.
public interface IFiddlerPreferences { // Indexer string this[string sName] {get; set; } // Setters void SetBoolPref(string sPrefName, bool bValue); void SetInt32Pref(string sPrefName, Int32 iValue); void SetStringPref(string sPrefName, string sValue); // Getters bool GetBoolPref(string sPrefName, bool bDefault); string GetStringPref(string sPrefName, string sDefault); Int32 GetInt32Pref(string sPrefName, Int32 iDefault); void RemovePref(string sPrefName); // Change Notification PreferenceBag.PrefWatcher AddWatcher(string sPrefixFilter, EventHandler<PrefChangeEventArgs> pcehHandler); void RemoveWatcher(PreferenceBag.PrefWatcher wliToRemove); }
Storing Preferences
You can store preferences using the Prefs.getStringPref, Prefs.getBoolPref, or Prefs.getIntPref APIs.
Alternatively, you can use the default indexer to store a string preference directly.
Retrieving Preferences
You can store preferences using the Prefs.getStringPref, Prefs.getBoolPref, or Prefs.getIntPref APIs.
Alternatively, you can use the default indexer to retrieve a string preference directly.
Removing Preferences
You can delete a Preference by calling Prefs.Remove("flagname").
Notification of Changes in Extensions
You can subscribe to receive notifications when preferences within a given branch change by attaching a Watcher.
oWatcher = FiddlerApplication.Prefs.AddWatcher(string sPrefixToMatch, EventHandler<PrefChangeEventArgs> fnToNotify);
To ensure proper garbage collection of objects, be sure to remove the Watcher when it is no longer needed.
FiddlerApplication.Prefs.RemoveWatcher(oWatcher);
Notification of Changes in FiddlerScript
To prevent a Watcher reference from preventing garbage collection of the script engine, scripts should instead use the WatchPreference function.
static function FnChange(o: Object, pceA: PrefChangeEventArgs){ if (null != pceA){ MessageBox.Show(pceA.PrefName + " changed to: " + pceA.ValueString); } else{ MessageBox.Show("Unexpected."); } } static function Main() { FiddlerObject.WatchPreference("fiddler.", FnChange); }
Fiddler will automatically take care of detaching the Watcher when a script engine unloads.
Profiles
Future versions of the Fiddler Preference system will support Profiles.