import System;
import System.Windows.Forms;
import Fiddler;
// INTRODUCTION
//
// Well, hello there!
//
// Don't be scared! :-)
//
// This is the FiddlerScript Rules file, which creates some of the menu commands and
// other features of Fiddler. You can edit this file to modify or add new commands.
//
// The original version of this file is named SampleRules.js and it is in the
// \Program Files\Fiddler\ folder. When Fiddler first runs, it creates a copy named
// CustomRules.js inside your \Documents\Fiddler2\Scripts folder. If you make a
// mistake in editing this file, simply delete the CustomRules.js file and restart
// Fiddler. A fresh copy of the default rules will be created from the original
// sample rules file.
// The best way to edit this file is to install the FiddlerScript Editor, part of
// the free SyntaxEditing addons. Get it here: http://fiddler2.com/r/?SYNTAXVIEWINSTALL
// GLOBALIZATION NOTE: Save this file using UTF-8 Encoding.
// JScript.NET Reference
// http://fiddler2.com/r/?msdnjsnet
//
// FiddlerScript Reference
// http://fiddler2.com/r/?fiddlerscriptcookbook
class Handlers
{
// *****************
//
// This is the Handlers class. Pretty much everything you ever add to FiddlerScript
// belongs right inside here, or inside one of the already-existing functions below.
//
// *****************
// The following snippet demonstrates a custom-bound column for the Web Sessions list.
// See http://fiddler2.com/r/?fiddlercolumns for more info
/*
public static BindUIColumn("Method", 60)
function FillMethodColumn(oS: Session): String {
return oS.RequestMethod;
}
*/
// The following snippet demonstrates how to create a custom tab that shows simple text
/*
public BindUITab("Flags")
static function FlagsReport(arrSess: Session[]):String {
var oSB: System.Text.StringBuilder = new System.Text.StringBuilder();
for (var i:int = 0; i<arrSess.Length; i++)
{
oSB.AppendLine("SESSION FLAGS");
oSB.AppendFormat("{0}: {1}\n", arrSess[i].id, arrSess[i].fullUrl);
for(var sFlag in arrSess[i].oFlags)
{
oSB.AppendFormat("\t{0}:\t\t{1}\n", sFlag.Key, sFlag.Value);
}
}
return oSB.ToString();
}
*/
// You can create a custom menu like so:
/*
QuickLinkMenu("&Links")
QuickLinkItem("IE GeoLoc TestDrive", "http://ie.microsoft.com/testdrive/HTML5/Geolocation/Default.html")
QuickLinkItem("FiddlerCore", "http://fiddler2.com/fiddlercore")
public static function DoLinksMenu(sText: String, sAction: String)
{
Utilities.LaunchHyperlink(sAction);
}
*/
public static RulesOption("关闭请求体转代码", "生成代码")
var m_DisableReuqest: boolean = false;
public static RulesOption("关闭返回体转代码", "生成代码")
var m_DisableResponse: boolean = false;
public static ContextAction("C#-httpclient", "生成代码")
function do1(arrSess: Session[]) { doStar(arrSess, "csharp","httpclient"); }
public static ContextAction("C#-restsharp", "生成代码")
function do2(arrSess: Session[]) { doStar(arrSess, "csharp","restsharp"); }
public static ContextAction("Java-okhttp", "生成代码")
function do3(arrSess: Session[]) { doStar(arrSess, "java","okhttp"); }
public static ContextAction("Java-asynchttp", "生成代码")
function do4(arrSess: Session[]) { doStar(arrSess, "java","asynchttp"); }
public static ContextAction("Java-nethttp", "生成代码")
function do5(arrSess: Session[]) { doStar(arrSess, "java","nethttp"); }
public static ContextAction("Java-unirest", "生成代码")
function do6(arrSess: Session[]) { doStar(arrSess, "java","unirest"); }
public static ContextAction("Kotlin-okhttp", "生成代码")
function do7(arrSess: Session[]) { doStar(arrSess, "kotlin","okhttp"); }
public static ContextAction("JavaScript-xhr", "生成代码")
function do8(arrSess: Session[]) { doStar(arrSess, "javascript","xhr"); }
public static ContextAction("JavaScript-jquery", "生成代码")
function do9(arrSess: Session[]) { doStar(arrSess, "javascript","jquery"); }
public static ContextAction("JavaScript-fetch", "生成代码")
function do10(arrSess: Session[]) { doStar(arrSess, "javascript","fetch"); }
public static ContextAction("JavaScript-axios", "生成代码")
function do11(arrSess: Session[]) { doStar(arrSess, "javascript","axios"); }
public static ContextAction("Node-native", "生成代码")
function do12(arrSess: Session[]) { doStar(arrSess, "node","native"); }
public static ContextAction("Node-request", "生成代码")
function do13(arrSess: Session[]) { doStar(arrSess, "node","request"); }
public static ContextAction("Node-fetch", "生成代码")
function do14(arrSess: Session[]) { doStar(arrSess, "node","fetch"); }
public static ContextAction("Node-axios", "生成代码")
function do15(arrSess: Session[]) { doStar(arrSess, "node","axios"); }
public static ContextAction("Node-unirest", "生成代码")
function do16(arrSess: Session[]) { doStar(arrSess, "node","unirest"); }
public static ContextAction("Python3-http.client", "生成代码")
function do17(arrSess: Session[]) { doStar(arrSess, "python","python3"); }
public static ContextAction("Python-requests", "生成代码")
function do18(arrSess: Session[]) { doStar(arrSess, "python","requests"); }
public static ContextAction("ObjectiveC-nsurlsession", "生成代码")
function do19(arrSess: Session[]) { doStar(arrSess, "objc","nsurlsession"); }
public static ContextAction("Ruby-net::http", "生成代码")
function do20(arrSess: Session[]) { doStar(arrSess, "ruby","native"); }
public static ContextAction("Swift-nsurlsession", "生成代码")
function do21(arrSess: Session[]) { doStar(arrSess, "swift","nsurlsession"); }
public static ContextAction("powershell-webrequest", "生成代码")
function do22(arrSess: Session[]) { doStar(arrSess, "powershell","webrequest"); }
public static ContextAction("powershell-restmethod", "生成代码")
function do23(arrSess: Session[]) { doStar(arrSess, "powershell","restmethod"); }
public static ContextAction("Shell-curl", "生成代码")
function do24(arrSess: Session[]) { doStar(arrSess, "shell","curl"); }
public static ContextAction("Shell-httpie", "生成代码")
function do25(arrSess: Session[]) { doStar(arrSess, "shell","httpie"); }
public static ContextAction("Shell-wget", "生成代码")
function do26(arrSess: Session[]) { doStar(arrSess, "shell","wget"); }
public static ContextAction("Go-NewRequest", "生成代码")
function do27(arrSess: Session[]) { doStar(arrSess, "go","native"); }
public static ContextAction("Clojure-clj_http", "生成代码")
function do28(arrSess: Session[]) { doStar(arrSess, "clojure","clj_http"); }
public static ContextAction("C-Libcurl", "生成代码")
function do29(arrSess: Session[]) { doStar(arrSess, "c","libcurl"); }
public static ContextAction("PHP-curl", "生成代码")
function do30(arrSess: Session[]) { doStar(arrSess, "php","curl"); }
public static ContextAction("PHP-http1", "生成代码")
function do31(arrSess: Session[]) { doStar(arrSess, "php","http1"); }
public static ContextAction("PHP-http2", "生成代码")
function do32(arrSess: Session[]) { doStar(arrSess, "php","http2"); }
public static function doStar(oSessions: Session[], target: String,client:String) {
//注意看这里,请下载我给的这2个exe并替换成你电脑中正确的目录
var httpsnippet = "E:\\workspace\\github\\test\\httpsnippet.exe";
var quicktype = "E:\\workspace\\github\\test\\quicktype.exe";
var oExportOptions = FiddlerObject.createDictionary();
var tempPath2 = System.IO.Path.Co