官方版

Use .NET Assemblies in FiddlerScript

To use a .NET addon (for this example, a C# addon that modifies the user-agent string):

Add References

  1. Close Fiddler.
  2. Save the .NET file (for example, this file called UASimulator.cs): ```vbnet using System; using System.Windows.Forms; using Fiddler;

namespace FiddlerUtility{

  1. public class UASimulator {
  2. string m_sUAString;
  3. public UASimulator(string s_UAString){
  4. m_sUAString = s_UAString;
  5. }
  6. public bool OverwriteUA(Session oSession){
  7. oSession.oRequest["User-Agent"] = m_sUAString;
  8. return true;
  9. }
  10. }

}

  1. 1. In a VS command prompt, go to the folder where the .CS file is found.<br />
  2. 1. Enter the command to create a DLL in the VS command prompt. For example:<br />
  3. ```vbnet
  4. csc /target:library /out:c:\UASim.dll UASimulator.cs /reference:"C:\program files\fiddler2\fiddler.exe"
  1. In Fiddler, click Tools > Fiddler Options.
  2. Click the Extensions tab.
  3. In the References field, enter the location of the DLL. For example:

    1. C:\UASim.dll

    Update Fiddler Rules

    Add a rule to Fiddler to update your script. For example:

    1. import System;
    2. import System.Windows.Forms;
    3. import Fiddler;
    4. import FiddlerUtility;
    5. class Handlers{
    6. static var UASim = new UASimulator("Mozilla/12.0");
    7. static function OnBeforeRequest(oSession:Fiddler.Session){
    8. UASim.OverwriteUA(oSession);
    9. }
    10. static function Main(){
    11. var today: Date = new Date();
    12. FiddlerObject.StatusText = " CustomRules.js was loaded at: " + today;
    13. }
    14. }

谷歌翻译版

在FiddlerScript中使用.NET程序集

要使用.NET插件(对于本示例,是一个修改用户代理字符串的C#插件):

添加参考

  1. 关闭Fiddler.
  2. 保存.NET文件(例如,此文件名为UASimulator.cs): ```vbnet using System; using System.Windows.Forms; using Fiddler;

namespace FiddlerUtility{

  1. public class UASimulator {
  2. string m_sUAString;
  3. public UASimulator(string s_UAString){
  4. m_sUAString = s_UAString;
  5. }
  6. public bool OverwriteUA(Session oSession){
  7. oSession.oRequest["User-Agent"] = m_sUAString;
  8. return true;
  9. }
  10. }

}

  1. 1. VS命令提示符中,转到. cs文件所在的文件夹。
  2. 1. VS命令提示符下输入命令以创建DLL 例如:
  3. ```vbnet
  4. csc /target:library /out:c:\UASim.dll UASimulator.cs /reference:"C:\program files\fiddler2\fiddler.exe"
  1. 在 Fiddler中, 点击 Tools > Fiddler Options.
  2. 单击 Extensions 选项卡.
  3. 在“References”字段中,输入DLL的位置。 例如:

    1. C:\UASim.dll

    更新Fiddler规则

    向Fiddler添加规则以更新脚本。 例如:

    1. import System;
    2. import System.Windows.Forms;
    3. import Fiddler;
    4. import FiddlerUtility;
    5. class Handlers{
    6. static var UASim = new UASimulator("Mozilla/12.0");
    7. static function OnBeforeRequest(oSession:Fiddler.Session){
    8. UASim.OverwriteUA(oSession);
    9. }
    10. static function Main(){
    11. var today: Date = new Date();
    12. FiddlerObject.StatusText = " CustomRules.js was loaded at: " + today;
    13. }
    14. }