Getting Meta content by name using HTMLAgility
ItemTitle = TrimString(document.DocumentNode.SelectSingleNode("//meta[@name='title']").Attributes["content"].Value);
ItemTitle = TrimString(document.DocumentNode.SelectSingleNode("//meta[@name='title']").Attributes["content"].Value);
public static RulesOption("Hide 304s") var m_Hide304s: boolean = false;What is that var declaration with a colon and a type? Well, good reader, that is likely the first and the last time you'll work with a language called JScript (also referred to as JScript.NET). I've leave the speculation (or research) up to you on how JScript ended up being the language of choice for custom rules. Let's just say it's a bit out of the way to locate a good set of documentation on this language. Hopefully you'll find examples that accomplish everything you need for your custom rule requirements either through a search or in the example below.
public static RulesOption("Free the Cookies!") var m_FreeTheCookies: boolean = false;You should now see the rule in the Rules menu. Clicking this item will enable it, so all that's left to do is add the code for the implementation. It's helpful to remember that your rule will need to be enabled every time you save the script file or close and reopen Fiddler (by default, at least).
if(m_FreeTheCookies) { for (var x:int = 0; x < oSession.oResponse.headers.Count(); x++) { if(oSession.oResponse.headers[x].Name.Contains("Set-Cookie")) { var cookie : Fiddler.HTTPHeaderItem = oSession.oResponse.headers[x]; if(cookie.Value.Contains("HttpOnly") || cookie.Value.Contains("secure;")) { FiddlerObject.log("Liberation time! Cookie to free: " + cookie.Value); cookie.Value = cookie.Value.Replace("HttpOnly", String.Empty).Replace("secure;", String.Empty); } } } }After re-enabling the rule and accessing your favorite web service with HttpOnly cookies, you should be in business.
private void BugFix_CookieDomain(CookieContainer cookieContainer) { System.Type _ContainerType = typeof(CookieContainer); Hashtable table = (Hashtable)_ContainerType.InvokeMember("m_domainTable", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.GetField | System.Reflection.BindingFlags.Instance, null, cookieContainer, new object[] { }); ArrayList keys = new ArrayList(table.Keys); foreach (string keyObj in keys) { string key = (keyObj as string); if (key[0] == '.') { string newKey = key.Remove(0, 1); table[newKey] = table[keyObj]; } } }
Uri target = new Uri("http://yourwebsite.com/login"); HttpWebRequest Crequest = (HttpWebRequest)WebRequest.Create(target); //reset MAINCookieContainer; MAINCookieContainer = new CookieContainer(); Crequest.CookieContainer = MAINCookieContainer; Crequest.Credentials = CredentialCache.DefaultCredentials; ((HttpWebRequest)Crequest).UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36"; Crequest.Method = "GET"; Crequest.ContentType = "application/x-www-form-urlencoded"; HttpWebResponse Cresponse = (HttpWebResponse)Crequest.GetResponse(); foreach (Cookie cookie in Cresponse.Cookies) { //add Cookie's to the MAINCookieContainer (the next HttpWebRequest will use them) MAINCookieContainer.Add(target, cookie); BugFix_CookieDomain(MAINCookieContainer); }