예제 #1
0
        private void FrmBrowser_Load(object sender, EventArgs e)
        {
            // Remove any existing session state data
            InternetSetOption(0, 42, null, 0);

            // Localize form
            this.Text      = localization.strings.please_login;
            LblSaving.Text = localization.strings.saving_info;

            // Delete Steam cookie data from the browser control
            InternetSetCookie("http://steamcommunity.com", "sessionid", ";expires=Mon, 01 Jan 0001 00:00:00 GMT");
            InternetSetCookie("http://steamcommunity.com", "steamLogin", ";expires=Mon, 01 Jan 0001 00:00:00 GMT");
            InternetSetCookie("http://steamcommunity.com", "steamRememberLogin", ";expires=Mon, 01 Jan 0001 00:00:00 GMT");

            // When the form is loaded, navigate to the Steam login page using the web browser control
            WbAuth.Navigate("https://steamcommunity.com/login/home/?goto=my/profile", "_self", null, "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko");
        }
예제 #2
0
        // 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();
            }
        }