// This code block executes each time a new document is loaded into the web browser control private void WbAuth_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { // Find the page header, and remove it. This gives the login form a more streamlined look. dynamic htmldoc = WbAuth.Document.DomDocument; dynamic globalHeader = htmldoc.GetElementById("global_header"); if (globalHeader != null) { try { globalHeader.parentNode.removeChild(globalHeader); } catch (Exception) { } } // Get the URL of the page that just finished loading var url = WbAuth.Url.AbsoluteUri; // If the page it just finished loading is the login page if (url == "https://steamcommunity.com/login/home/?goto=my/profile" || url == "https://store.steampowered.com/login/transfer" || url == "https://store.steampowered.com//login/transfer") { // Get a list of cookies from the current page CookieContainer container = GetUriCookieContainer(WbAuth.Url); var cookies = container.GetCookies(WbAuth.Url); foreach (Cookie cookie in cookies) { if (cookie.Name.StartsWith("steamMachineAuth")) { Settings.Default.steamMachineAuth = cookie.Value; } } } // If the page it just finished loading isn't the login page else if (url.StartsWith("javascript:") == false && url.StartsWith("about:") == false) { try { dynamic parentalNotice = htmldoc.GetElementById("parental_notice"); if (parentalNotice != null) { if (parentalNotice.OuterHtml != "") { // Steam family options enabled WbAuth.Show(); Width = 1000; Height = 350; return; } } } catch (Exception) { } // Get a list of cookies from the current page var container = GetUriCookieContainer(WbAuth.Url); var cookies = container.GetCookies(WbAuth.Url); // Go through the cookie data so that we can extract the cookies we are looking for foreach (Cookie cookie in cookies) { // Save the "sessionid" cookie if (cookie.Name == "sessionid") { Settings.Default.sessionid = cookie.Value; } // Save the "steamLogin" cookie and construct and save the user's profile link // steamLogin is now Change to steamLoginSecure /*else if (cookie.Name == "steamLogin") * { * Settings.Default.steamLogin = cookie.Value; * Settings.Default.myProfileURL = SteamProfile.GetSteamUrl(); * }*/ // Save the "steamLogin" cookie and construct and save the user's profile link else if (cookie.Name == "steamLoginSecure") { Settings.Default.steamLoginSecure = cookie.Value; Settings.Default.myProfileURL = SteamProfile.GetSteamUrl(); } else if (cookie.Name == "steamRememberLogin") { Settings.Default.steamRememberLogin = cookie.Value; } else if (cookie.Name == "steamparental") { Settings.Default.steamparental = cookie.Value; } } // Save all of the data to the program settings file, and close this form Settings.Default.Save(); Close(); } }