Use .NET Assemblies in FiddlerScript
To use a .NET addon (for this example, a C# addon that modifies the user-agent string):
Add References
Close Fiddler.
-
Save the .NET file (for example, this file called UASimulator.cs):
using System; using System.Windows.Forms; using Fiddler; namespace FiddlerUtility{ public class UASimulator { string m_sUAString; public UASimulator(string s_UAString){ m_sUAString = s_UAString; } public bool OverwriteUA(Session oSession){ oSession.oRequest["User-Agent"] = m_sUAString; return true; } } }
In a VS command prompt, go to the folder where the .CS file is found.
-
Enter the command to create a DLL in the VS command prompt. For example:
csc /target:library /out:c:\UASim.dll UASimulator.cs /reference:"%localappdata%\Programs\Fiddler\fiddler.exe"
In Fiddler, click Tools > Options.
Click the Extensions tab.
-
In the References field, enter the location of the DLL. For example:
C:\UASim.dll
Update Fiddler Classic Rules
Add a rule to Fiddler Classic to update your script. For example:
import System;
import System.Windows.Forms;
import Fiddler;
import FiddlerUtility;
class Handlers{
static var UASim = new UASimulator("Mozilla/12.0");
static function OnBeforeRequest(oSession:Fiddler.Session){
UASim.OverwriteUA(oSession);
}
static function Main(){
var today: Date = new Date();
FiddlerObject.StatusText = " CustomRules.js was loaded at: " + today;
}
}