官方版
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): ```vbnet 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;
}
}
}
1. In a VS command prompt, go to the folder where the .CS file is found.<br />
1. Enter the command to create a DLL in the VS command prompt. For example:<br />
```vbnet
csc /target:library /out:c:\UASim.dll UASimulator.cs /reference:"C:\program files\fiddler2\fiddler.exe"
- In Fiddler, click Tools > Fiddler Options.
- Click the Extensions tab.
In the References field, enter the location of the DLL. For example:
C:\UASim.dll
Update Fiddler Rules
Add a rule to Fiddler 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;
}
}
谷歌翻译版
在FiddlerScript中使用.NET程序集
要使用.NET插件(对于本示例,是一个修改用户代理字符串的C#插件):
添加参考
- 关闭Fiddler.
- 保存.NET文件(例如,此文件名为UASimulator.cs): ```vbnet 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;
}
}
}
1. 在VS命令提示符中,转到. cs文件所在的文件夹。
1. 在VS命令提示符下输入命令以创建DLL。 例如:
```vbnet
csc /target:library /out:c:\UASim.dll UASimulator.cs /reference:"C:\program files\fiddler2\fiddler.exe"
- 在 Fiddler中, 点击 Tools > Fiddler Options.
- 单击 Extensions 选项卡.
在“References”字段中,输入DLL的位置。 例如:
C:\UASim.dll
更新Fiddler规则
向Fiddler添加规则以更新脚本。 例如:
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;
}
}