Advertisement
Sycdan

Fiddler2 LoaTS Cache Script

Nov 27th, 2012
1,332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import System;
  2. import System.Windows.Forms;
  3. import Fiddler;
  4.  
  5.  
  6. // INTRODUCTION
  7. // This is the FiddlerScript Rules file, which creates some of the menu commands and
  8. // other features of Fiddler. You can edit this file to modify or add new commands.
  9. //
  10. // The original version of this file is named SampleRules.js and it is in the
  11. // \Program Files\Fiddler\ folder. When Fiddler first starts, it creates a copy named
  12. // CustomRules.js inside your \Documents\Fiddler2\Scripts folder. If you make a
  13. // mistake in editing this file, simply delete the CustomRules.js file and restart
  14. // Fiddler. A fresh copy of the default rules will be created from the original
  15. // sample rules file.
  16.  
  17. // GLOBALIZATION NOTE:
  18. // Be sure to save this file with UTF-8 Encoding if using any non-ASCII characters
  19. // in strings, etc.
  20.  
  21. // JScript Reference
  22. // http://www.fiddler2.com/redir/?id=msdnjsnet
  23. //
  24. // FiddlerScript Reference
  25. // http://www.fiddler2.com/redir/?id=fiddlerscriptcookbook
  26. //
  27. // FiddlerScript Editor:
  28. // http://www.fiddler2.com/redir/?id=fiddlerscripteditor
  29.  
  30. class Handlers
  31. {
  32.     // The following snippet demonstrates a custom-bound column for the web sessions list.
  33.     // See http://www.fiddler2.com/fiddler/help/configurecolumns.asp for more info
  34.     // public static BindUIColumn("Method", 60)
  35.     // function FillMethodColumn(oS: Session){
  36.     //  if ((oS.oRequest != null) && (oS.oRequest.headers != null))
  37.     //  return oS.oRequest.headers.HTTPMethod; else return String.Empty;
  38.     //}
  39.  
  40.     public static RulesOption("Hide 304s")
  41.     var m_Hide304s: boolean = false;
  42.  
  43.     // Cause Fiddler to override the Accept-Language header with one of the defined values
  44.     public static RulesOption("Request &Japanese Content")
  45.     var m_Japanese: boolean = false;   
  46.  
  47.     // Automatic Authentication
  48.     public static RulesOption("&Automatically Authenticate")
  49.     var m_AutoAuth: boolean = false;
  50.  
  51.     // Cause Fiddler to override the User-Agent header with one of the defined values
  52.     RulesString("&User-Agents", true)
  53.     RulesStringValue(0,"Netscape &3", "Mozilla/3.0 (Win95; I)")
  54.     RulesStringValue(1,"WinPhone7", "Mozilla/4.0 (compatible: MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0; SAMSUNG; SGH-i917)")
  55.     RulesStringValue(2,"WinPhone7.5", "Mozilla/5.0 (compatible: MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; SAMSUNG; SGH-i917)")
  56.     RulesStringValue(3,"&Safari5 (Win7)", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1")
  57.     RulesStringValue(4,"Safari6 (Mac)", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8) AppleWebKit/536.25 (KHTML, like Gecko) Version/6.0 Safari/536.25")
  58.     RulesStringValue(5,"IPAD", "Mozilla/5.0 (iPad; CPU OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3")  
  59.     RulesStringValue(6,"IE &6 (XPSP2)", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)")
  60.     RulesStringValue(7,"IE &7 (Vista)", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1)")
  61.     RulesStringValue(8,"IE 8 (Win2k3 x64)", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; WOW64; Trident/4.0)")
  62.     RulesStringValue(9,"IE &8 (Win7)", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)")
  63.     RulesStringValue(10,"IE 8 (IE7 CompatMode)", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0)")
  64.     RulesStringValue(11,"IE 9 (Win7)", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)")
  65.     RulesStringValue(12,"IE 10 (Win8)", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)")
  66.     RulesStringValue(13,"&Opera", "Opera/9.80 (Windows NT 6.1; U; en) Presto/2.10.229 Version/11.61")
  67.     RulesStringValue(14,"&Firefox 3.6", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.7) Gecko/20100625 Firefox/3.6.7")
  68.     RulesStringValue(15,"&Firefox 4", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1")
  69.     RulesStringValue(16,"&Firefox 14", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20100101 Firefox/14.0")
  70.     RulesStringValue(17,"&Firefox (Mac)", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3")
  71.     RulesStringValue(18,"Chrome", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5")
  72.     RulesStringValue(19,"GoogleBot Crawler", "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)")
  73.     RulesStringValue(20,"Kindle Fire (Silk)", "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.0.22.79_10013310) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true")
  74.     RulesStringValue(21,"&Custom...", "%CUSTOM%")
  75.     public static var sUA: String = null;
  76.  
  77.     // Cause Fiddler to delay HTTP traffic to simulate typical 56k modem conditions
  78.     public static RulesOption("Simulate &Modem Speeds", "Per&formance")
  79.     var m_SimulateModem: boolean = false;
  80.  
  81.     // Removes HTTP-caching related headers and specifies "no-cache" on requests and responses
  82.     public static RulesOption("&Disable Caching", "Per&formance")
  83.     var m_DisableCaching: boolean = false;
  84.  
  85.     // Show the duration between the start of Request.Send and Response.Completed in Milliseconds
  86.     public static RulesOption("&Show Time-to-Last-Byte", "Per&formance")
  87.     var m_ShowTTLB: boolean = false;
  88.  
  89.     // Show the time of response completion
  90.     public static RulesOption("Show Response &Timestamp", "Per&formance")
  91.     var m_ShowTimestamp: boolean = false;
  92.  
  93.     public static RulesOption("Cache Always &Fresh", "Per&formance")
  94.     var m_AlwaysFresh: boolean = false;
  95.        
  96.     // Force a manual reload of the script file.  Resets all
  97.     // RulesOption variables to their defaults.
  98.     public static ToolsAction("Reset Script")
  99.     function DoManualReload() {
  100.         FiddlerObject.ReloadScript();
  101.     }
  102.  
  103.     public static ContextAction("Decode Selected Sessions")
  104.     function DoRemoveEncoding(oSessions: Session[]) {
  105.         for (var x:int = 0; x < oSessions.Length; x++){
  106.             oSessions[x].utilDecodeRequest();
  107.             oSessions[x].utilDecodeResponse();
  108.         }
  109.     }
  110.  
  111.     static function OnBoot() {
  112.         // MessageBox.Show("Fiddler has finished booting");
  113.         // System.Diagnostics.Process.Start("iexplore.exe");
  114.  
  115.         // FiddlerObject.UI.ActivateRequestInspector("HEADERS");
  116.         // FiddlerObject.UI.ActivateResponseInspector("HEADERS");
  117.     }
  118.    
  119.     static function OnShutdown() {
  120.         // MessageBox.Show("Fiddler has shutdown");
  121.     }
  122.  
  123.     static function OnAttach() {
  124.         // MessageBox.Show("Fiddler is now the system proxy");
  125.         // System.Diagnostics.Process.Start("proxycfg.exe", "-u");  // Notify WinHTTP of proxy change
  126.     }
  127.  
  128.     static function OnDetach() {
  129.         // MessageBox.Show("Fiddler is no longer the system proxy");
  130.         // System.Diagnostics.Process.Start("proxycfg.exe", "-u");  // Notify WinHTTP of proxy change
  131.     }
  132.  
  133.     static function fpgCachePath(){return "C:/Users/USERNAME/Documents/Fiddler2/Captures/Responses";}
  134.        
  135.     static function fpgCacheFilePath(oSession: Session) {return (fpgCachePath() + oSession.PathAndQuery).Replace("/", "\\");}
  136.        
  137.     static function fpgAskCache(oSession: Session) {
  138.         if (oSession.HostnameIs("5thplanetgames-origin.cdnetworks.net") && oSession.uriContains("/lots_live/images/")) {
  139.        
  140.             //FiddlerApplication.Log.LogString("###");
  141.             //FiddlerApplication.Log.LogString("Request for " + oSession.PathAndQuery);
  142.            
  143.             var fp = (fpgCachePath() + oSession.PathAndQuery).Replace("/", "\\");
  144.            
  145.             if (fpgIsCached(oSession) == true) {
  146.                 //FiddlerApplication.Log.LogString("Using cached file " + fp);
  147.                 oSession["x-replywithfile"] = oSession.PathAndQuery.Substring(1).Replace("/", "\\");
  148.                 oSession["ui-color"] = "green"
  149.                
  150.             }
  151.         }
  152.     }
  153.        
  154.     static function fpgIsCached(oSession: Session) {
  155.         // Store the current request body
  156.         var bak = oSession.RequestBody.Clone();
  157.            
  158.         // Check for file existence, by attepmting to load the requested file as the request body
  159.         var exists = oSession.LoadRequestBodyFromFile(fpgCacheFilePath(oSession));
  160.            
  161.         // Reinstate the request
  162.         oSession.RequestBody = bak;
  163.        
  164.         return exists;
  165.        
  166.     }
  167.        
  168.     static function fpgSaveToCache(oSession: Session) {
  169.         if (oSession.HostnameIs("5thplanetgames-origin.cdnetworks.net") && oSession.uriContains("/lots_live/images/")) {
  170.             if (oSession.responseCode == 200 && fpgIsCached(oSession) == false) {
  171.                 var fp = fpgCacheFilePath(oSession);
  172.                 //FiddlerApplication.Log.LogString("Caching file " + fp);
  173.                 oSession.SaveResponseBody(fp);
  174.                 oSession["ui-color"] = "blue";
  175.             }
  176.            
  177.         }
  178.     }
  179.            
  180. static function OnBeforeRequest(oSession: Session) {
  181.     // Sample Rule: Color ASPX requests in RED
  182.     // if (oSession.uriContains(".aspx")) { oSession["ui-color"] = "red";   }
  183.  
  184.     // Sample Rule: Flag POSTs to fiddler2.com in italics
  185.     // if (oSession.HostnameIs("www.fiddler2.com") && oSession.HTTPMethodIs("POST")) {  oSession["ui-italic"] = "yup";  }
  186.  
  187.     // Sample Rule: Break requests for URLs containing "/sandbox/"
  188.     // if (oSession.uriContains("/sandbox/")) {
  189.     //     oSession.oFlags["x-breakrequest"] = "yup";   // Existence of the x-breakrequest flag creates a breakpoint; the "yup" value is unimportant.
  190.     // }
  191.        
  192.    
  193.     fpgAskCache(oSession);
  194.  
  195.  
  196.     if ((null != gs_ReplaceToken) && (oSession.url.indexOf(gs_ReplaceToken)>-1)) {   // Case sensitive
  197.         oSession.url = oSession.url.Replace(gs_ReplaceToken, gs_ReplaceTokenWith);
  198.     }
  199.     if ((null != gs_OverridenHost) && (oSession.host.toLowerCase() == gs_OverridenHost)) {
  200.         oSession["x-overridehost"] = gs_OverrideHostWith;
  201.     }
  202.  
  203.     if ((null!=bpRequestURI) && oSession.uriContains(bpRequestURI)) {
  204.         oSession["x-breakrequest"]="uri";
  205.     }
  206.  
  207.     if ((null!=bpMethod) && (oSession.HTTPMethodIs(bpMethod))) {
  208.         oSession["x-breakrequest"]="method";
  209.     }
  210.  
  211.     if ((null!=uiBoldURI) && oSession.uriContains(uiBoldURI)) {
  212.         oSession["ui-bold"]="QuickExec";
  213.     }
  214.  
  215.     if (m_SimulateModem) {
  216.         // Delay sends by 300ms per KB uploaded.
  217.         oSession["request-trickle-delay"] = "300";
  218.         // Delay receives by 150ms per KB downloaded.
  219.         oSession["response-trickle-delay"] = "150";
  220.     }
  221.  
  222.     if (m_DisableCaching) {
  223.         oSession.oRequest.headers.Remove("If-None-Match");
  224.         oSession.oRequest.headers.Remove("If-Modified-Since");
  225.         oSession.oRequest["Pragma"] = "no-cache";
  226.     }
  227.  
  228.     // User-Agent Overrides
  229.     if (null != sUA) {
  230.         oSession.oRequest["User-Agent"] = sUA;
  231.     }
  232.  
  233.     if (m_Japanese) {
  234.         oSession.oRequest["Accept-Language"] = "ja";
  235.     }
  236.  
  237.     if (m_AutoAuth) {
  238.         // Automatically respond to any authentication challenges using the
  239.         // current Fiddler user's credentials. You can change (default)
  240.         // to a domain\\username:password string if preferred.
  241.         //
  242.         // WARNING: This setting poses a security risk if remote
  243.         // connections are permitted!
  244.         oSession["X-AutoAuth"] = "(default)";
  245.     }
  246.  
  247.     if (m_AlwaysFresh && (oSession.oRequest.headers.Exists("If-Modified-Since") || oSession.oRequest.headers.Exists("If-None-Match")))
  248.     {
  249.         oSession.utilCreateResponseAndBypassServer();
  250.         oSession.responseCode = 304;
  251.         oSession["ui-backcolor"] = "Lavender";
  252.     }
  253. }
  254.  
  255. /*
  256.     // This function is called immediately after a set of request headers has
  257.     // been read from the client. This is typically too early to do much useful
  258.     // work, since the body hasn't yet been read, but sometimes it may be useful.
  259.     //
  260.     // For instance, see
  261.     // http://blogs.msdn.com/b/fiddler/archive/2011/11/05/http-expect-continue-delays-transmitting-post-bodies-by-up-to-350-milliseconds.aspx
  262.     // for one useful thing you can do with this handler.
  263.     //
  264.     // Note: oSession.requestBodyBytes is not available within this function!
  265.     static function OnPeekAtRequestHeaders(oSession: Session) {
  266.     }
  267. */
  268.  
  269.     //
  270.     // If a given session has response streaming enabled, then the OnBeforeResponse function
  271.     // is actually called AFTER the response was returned to the client.
  272.     //
  273.     // In contrast, this OnPeekAtResponseHeaders function is called before the response headers are
  274.     // sent to the client (and before the body is read from the server).  Hence this is an opportune time
  275.     // to disable streaming (oSession.bBufferResponse = true) if there is something in the response headers
  276.     // which suggests that tampering with the response body is necessary.
  277.     //
  278.     // Note: oSession.responseBodyBytes is not available within this function!
  279.     //
  280. static function OnPeekAtResponseHeaders(oSession: Session) {
  281.        
  282.     //FiddlerApplication.Log.LogFormat("Session {0}: Response header peek shows status is {1}", oSession.id, oSession.responseCode);
  283.     if (m_DisableCaching) {
  284.         oSession.oResponse.headers.Remove("Expires");
  285.         oSession.oResponse["Cache-Control"] = "no-cache";
  286.     }
  287.  
  288.     if ((bpStatus>0) && (oSession.responseCode == bpStatus)) {
  289.         oSession["x-breakresponse"]="status";
  290.         oSession.bBufferResponse = true;
  291.     }
  292.        
  293.     if ((null!=bpResponseURI) && oSession.uriContains(bpResponseURI)) {
  294.         oSession["x-breakresponse"]="uri";
  295.         oSession.bBufferResponse = true;
  296.     }
  297.        
  298.  
  299. }
  300.  
  301.     static function OnBeforeResponse(oSession: Session) {
  302.    
  303.         fpgSaveToCache(oSession);
  304.        
  305.         //save grooveshark streams
  306.         if (/grooveshark\.com/i.test(oSession.hostname)  && oSession.uriContains("/stream.php")) {
  307.             oSession.SaveResponseBody(fpgCachePath() + "/" + oSession.SuggestedFilename);
  308.         }
  309.        
  310.         if (m_ShowTimestamp){
  311.             oSession["ui-customcolumn"] = DateTime.Now.ToString("H:mm:ss.ffff") + " " + oSession["ui-customcolumn"];
  312.         }
  313.  
  314.         if (m_ShowTTLB){
  315.             oSession["ui-customcolumn"] = oSession.oResponse.iTTLB + "ms " + oSession["ui-customcolumn"];
  316.         }
  317.  
  318.         if (m_Hide304s && oSession.responseCode == 304){
  319.             oSession["ui-hide"] = "true";
  320.         }
  321.     }
  322.  
  323. /*
  324.     // This function executes just before Fiddler returns an error that it has
  325.     // itself generated (e.g. "DNS Lookup failure") to the client application.
  326.     // These responses will not run through the OnBeforeResponse function above.
  327.     static function OnReturningError(oSession: Session) {
  328.     }
  329. */
  330.  
  331. static function Main() {
  332.     var today: Date = new Date();
  333.     FiddlerObject.StatusText = " CustomRules.js was loaded at: " + today;
  334.     // Uncomment to add a "Server" column containing the response "Server" header, if present
  335.     // FiddlerObject.UI.lvSessions.AddBoundColumn("Server", 50, "@response.server");
  336. }
  337.  
  338.     // These static variables are used for simple breakpointing & other QuickExec rules
  339. static var bpRequestURI:String = null;
  340. static var bpResponseURI:String = null;
  341. static var bpStatus:int = -1;
  342. static var bpMethod: String = null;
  343. static var uiBoldURI: String = null;
  344. static var gs_ReplaceToken: String = null;
  345. static var gs_ReplaceTokenWith: String = null;
  346. static var gs_OverridenHost: String = null;
  347. static var gs_OverrideHostWith: String = null;
  348.  
  349.     // The OnExecAction function is called by either the QuickExec box in the Fiddler window,
  350.     // or by the ExecAction.exe command line utility.
  351. static function OnExecAction(sParams: String[]) {
  352.  
  353.     FiddlerObject.StatusText = "ExecAction: " + sParams[0];
  354.  
  355.     var sAction = sParams[0].toLowerCase();
  356.     switch (sAction) {
  357.         case "bold":
  358.             if (sParams.Length<2) {uiBoldURI=null; FiddlerObject.StatusText="Bolding cleared"; return;}
  359.             uiBoldURI = sParams[1]; FiddlerObject.StatusText="Bolding requests for " + uiBoldURI;
  360.             break;
  361.         case "bp":
  362.             FiddlerObject.alert("bpu = breakpoint request for uri\nbpm = breakpoint request method\nbps=breakpoint response status\nbpafter = breakpoint response for URI");
  363.             break;
  364.         case "bps":
  365.             if (sParams.Length<2) {bpStatus=-1; FiddlerObject.StatusText="Response Status breakpoint cleared"; return;}
  366.             bpStatus = parseInt(sParams[1]); FiddlerObject.StatusText="Response status breakpoint for " + sParams[1];
  367.             break;
  368.         case "bpv":
  369.         case "bpm":
  370.             if (sParams.Length<2) {bpMethod=null; FiddlerObject.StatusText="Request Method breakpoint cleared"; return;}
  371.             bpMethod = sParams[1].toUpperCase(); FiddlerObject.StatusText="Request Method breakpoint for " + bpMethod;
  372.             break;
  373.         case "bpu":
  374.             if (sParams.Length<2) {bpRequestURI=null; FiddlerObject.StatusText="RequestURI breakpoint cleared"; return;}
  375.             bpRequestURI = sParams[1];
  376.             FiddlerObject.StatusText="RequestURI breakpoint for "+sParams[1];
  377.             break;
  378.         case "bpafter":
  379.             if (sParams.Length<2) {bpResponseURI=null; FiddlerObject.StatusText="ResponseURI breakpoint cleared"; return;}
  380.             bpResponseURI = sParams[1];
  381.             FiddlerObject.StatusText="ResponseURI breakpoint for "+sParams[1];
  382.             break;
  383.         case "overridehost":
  384.             if (sParams.Length<3) {gs_OverridenHost=null; FiddlerObject.StatusText="Host Override cleared"; return;}
  385.             gs_OverridenHost = sParams[1].toLowerCase();
  386.             gs_OverrideHostWith = sParams[2];
  387.             FiddlerObject.StatusText="Connecting to [" + gs_OverrideHostWith + "] for requests to [" + gs_OverridenHost + "]";
  388.             break;
  389.         case "urlreplace":
  390.             if (sParams.Length<3) {gs_ReplaceToken=null; FiddlerObject.StatusText="URL Replacement cleared"; return;}
  391.             gs_ReplaceToken = sParams[1];
  392.             gs_ReplaceTokenWith = sParams[2].Replace(" ", "%20");  // Simple helper
  393.             FiddlerObject.StatusText="Replacing [" + gs_ReplaceToken + "] in URIs with [" + gs_ReplaceTokenWith + "]";
  394.             break;
  395.         case "allbut":
  396.         case "keeponly":
  397.             if (sParams.Length<2) { FiddlerObject.StatusText="Please specify Content-Type to retain during wipe."; return;}
  398.             FiddlerObject.UI.actSelectSessionsWithResponseHeaderValue("Content-Type", sParams[1]);
  399.             FiddlerObject.UI.actRemoveUnselectedSessions();
  400.             FiddlerObject.UI.lvSessions.SelectedItems.Clear();
  401.             FiddlerObject.StatusText="Removed all but Content-Type: " + sParams[1];
  402.             break;
  403.         case "stop":
  404.             FiddlerObject.UI.actDetachProxy();
  405.             break;
  406.         case "start":
  407.             FiddlerObject.UI.actAttachProxy();
  408.             break;
  409.         case "cls":
  410.         case "clear":
  411.             FiddlerObject.UI.actRemoveAllSessions();
  412.             break;
  413.         case "g":
  414.         case "go":
  415.             FiddlerObject.UI.actResumeAllSessions();
  416.             break;
  417.         case "goto":
  418.             if (sParams.Length != 2) return;
  419.             Utilities.LaunchHyperlink("http://www.google.com/search?hl=en&btnI=I%27m+Feeling+Lucky&q=" + Utilities.UrlEncode(sParams[1]));
  420.             break;
  421.         case "help":
  422.             Utilities.LaunchHyperlink("http://www.fiddler2.com/redir/?id=quickexec");
  423.             break;
  424.         case "hide":
  425.             FiddlerObject.UI.actMinimizeToTray();
  426.             break;
  427.         case "log":
  428.             FiddlerApplication.Log.LogString((sParams.Length<2) ? FiddlerApplication.Log.LogString("User couldn't think of anything to say...") : sParams[1]);
  429.             break;
  430.         case "nuke":
  431.             FiddlerObject.UI.actClearWinINETCache();
  432.             FiddlerObject.UI.actClearWinINETCookies();
  433.             break;
  434.         case "show":
  435.             FiddlerObject.UI.actRestoreWindow();
  436.             break;
  437.         case "tail":
  438.             if (sParams.Length<2) { FiddlerObject.StatusText="Please specify # of sessions to trim the session list to."; return;}
  439.             FiddlerObject.UI.TrimSessionList(int.Parse(sParams[1]));
  440.             break;
  441.         case "quit":
  442.             FiddlerObject.UI.actExit();
  443.             break;
  444.         case "dump":
  445.             FiddlerObject.UI.actSelectAll();
  446.             FiddlerObject.UI.actSaveSessionsToZip(CONFIG.GetPath("Captures") + "dump.saz");
  447.             FiddlerObject.UI.actRemoveAllSessions();
  448.             FiddlerObject.StatusText = "Dumped all sessions to " + CONFIG.GetPath("Captures") + "dump.saz";
  449.             break;
  450.  
  451.         default:
  452.             if (sAction.StartsWith("http") || sAction.StartsWith("www")){
  453.                 System.Diagnostics.Process.Start(sParams[0]);
  454.             }
  455.             else
  456.             {
  457.                 FiddlerObject.StatusText = "Requested ExecAction: '" + sAction + "' not found. Type HELP to learn more.";
  458.             }
  459.     }
  460. }
  461.    
  462.     public static ContextAction("Dump Files")
  463.     function DoDumpFiles(oSessions: Fiddler.Session[])
  464.     {
  465.         if (null == oSessions){
  466.             MessageBox.Show("Please select sessions to dump.", "Nothing to Do");
  467.             return;
  468.         }
  469.    
  470.         for (var x = 0; x < oSessions.Length; x++){
  471.             oSessions[x].SaveResponseBody();
  472.         }
  473.         MessageBox.Show("Done.");
  474.     }
  475. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement