Ejemplo n.º 1
0
        private async void tmrReadyToGo_Tick(object sender, EventArgs e)
        {
            if (!IsCookieReady || !IsSteamReady)
            {
                return;
            }

            // Update the form elements
            if (Settings.Default.showUsername)
            {
                lblSignedOnAs.Text    = SteamProfile.GetSignedAs();
                lblSignedOnAs.Visible = true;
            }

            lblDrops.Visible       = true;
            lblDrops.Text          = localization.strings.reading_badge_page + ", " + localization.strings.please_wait;
            lblIdle.Visible        = false;
            picReadingPage.Visible = true;

            tmrReadyToGo.Enabled = false;

            // Call the loadBadges() function asynchronously
            await LoadBadgesAsync();

            StartIdle();
        }
Ejemplo n.º 2
0
        private void extractSteamCookies()
        {
            var container = GetUriCookieContainer(wbAuth.Url);
            var cookies   = container.GetCookies(wbAuth.Url);

            foreach (Cookie cookie in cookies)
            {
                if (cookie.Name == "sessionid")
                {
                    Settings.Default.sessionid = cookie.Value;
                }
                else if (cookie.Name == "steamLogin")
                {
                    Settings.Default.steamLogin   = cookie.Value;
                    Settings.Default.myProfileURL = SteamProfile.GetSteamUrl();
                }
                else if (cookie.Name == "steamLoginSecure")
                {
                    Settings.Default.steamLoginSecure = cookie.Value;
                    Settings.Default.myProfileURL     = SteamProfile.GetSteamUrl();
                }
                else if (cookie.Name == "steamparental")
                {
                    Settings.Default.steamparental = cookie.Value;
                }
                else if (cookie.Name == "steamRememberLogin")
                {
                    Settings.Default.steamRememberLogin = cookie.Value;
                }
            }

            Settings.Default.Save();
        }
Ejemplo n.º 3
0
        private void extractSteamCookies()
        {
            // 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
                else if (cookie.Name == "steamLogin")
                {
                    Settings.Default.steamLogin   = cookie.Value;
                    Settings.Default.myProfileURL = SteamProfile.GetSteamUrl();
                }

                else if (cookie.Name == "steamLoginSecure")
                {
                    Settings.Default.steamLoginSecure = cookie.Value;
                    Settings.Default.myProfileURL     = SteamProfile.GetSteamUrl();
                }

                // Save the "steamparental" cookie"
                else if (cookie.Name == "steamparental")
                {
                    Settings.Default.steamparental = cookie.Value;
                }

                else if (cookie.Name == "steamRememberLogin")
                {
                    Settings.Default.steamRememberLogin = cookie.Value;
                }
            }

            // Save all of the data to the program settings file, and close this form
            Settings.Default.Save();
        }
Ejemplo n.º 4
0
        private async Task CheckAndSave()
        {
            try
            {
                Settings.Default.sessionid        = txtSessionID.Text.Trim();
                Settings.Default.steamLogin       = txtSteamLogin.Text.Trim();
                Settings.Default.steamLoginSecure = txtSteamLoginSecure.Text.Trim();
                Settings.Default.myProfileURL     = SteamProfile.GetSteamUrl();
                Settings.Default.steamparental    = txtSteamParental.Text.Trim();

                if (await CookieClient.IsLogined())
                {
                    Settings.Default.Save();
                    Close();
                    return;
                }
            }
            catch (Exception ex)
            {
                Logger.Exception(ex, "frmSettingsAdvanced -> CheckAndSave");
            }

            // Invalid cookie data, reset the form
            btnUpdate.Text                   = localization.strings.update;
            txtSessionID.Text                = "";
            txtSteamLogin.Text               = "";
            txtSteamLoginSecure.Text         = "";
            txtSteamParental.Text            = "";
            txtSessionID.PasswordChar        = '\0';
            txtSteamLogin.PasswordChar       = '\0';
            txtSteamLoginSecure.PasswordChar = '\0';
            txtSteamParental.PasswordChar    = '\0';
            txtSessionID.Enabled             = true;
            txtSteamLogin.Enabled            = true;
            txtSteamLoginSecure.Enabled      = true;
            txtSteamParental.Enabled         = true;
            txtSessionID.Focus();
            MessageBox.Show(localization.strings.validate_failed);
            btnUpdate.Enabled = true;
        }
Ejemplo n.º 5
0
        private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Show the form
            String  previous          = Settings.Default.sort;
            Boolean previous_behavior = Settings.Default.OnlyOneGameIdle;
            Form    frm = new frmSettings();

            frm.ShowDialog();

            if (previous != Settings.Default.sort || previous_behavior != Settings.Default.OnlyOneGameIdle)
            {
                StopIdle();
                AllBadges.Clear();
                tmrReadyToGo.Enabled = true;
            }

            if (Settings.Default.showUsername && IsCookieReady)
            {
                lblSignedOnAs.Text    = SteamProfile.GetSignedAs();
                lblSignedOnAs.Visible = Settings.Default.showUsername;
            }
        }
Ejemplo n.º 6
0
        private async void tmrReadyToGo_Tick(object sender, EventArgs e)
        {
            //以下是魔改代码
            try
            {
                //获取自动下一个间隔时间
                StringBuilder temp = new StringBuilder(500);
                GetPrivateProfileString("AutoNext", "Time", "500", temp, 500, ".\\Settings.ini");
                if (temp.ToString() == "")
                {
                    AutoNextTime = 500;
                }
                else
                {
                    AutoNextTime         = Convert.ToInt32(temp.ToString());
                    tmrAutoNext.Interval = AutoNextTime;
                }
                //获取最小运行时间
                temp = new StringBuilder(500);
                GetPrivateProfileString("AutoNext", "MinRuntime", "2", temp, 500, ".\\Settings.ini");
                if (temp.ToString() == "")
                {
                    MinRuntime = 2;
                }
                else
                {
                    MinRuntime = Convert.ToInt32(temp.ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("程序发生错误,即将退出!\r\n错误信息:" + ex.Message);
                System.Environment.Exit(0);
            }

            if (!IsCookieReady || !IsSteamReady)
            {
                return;
            }

            // Update the form elements
            if (Settings.Default.showUsername)
            {
                lblSignedOnAs.Text    = SteamProfile.GetSignedAs();
                lblSignedOnAs.Visible = true;
            }

            lblDrops.Visible       = true;
            lblDrops.Text          = localization.strings.reading_badge_page + ", " + localization.strings.please_wait;
            lblIdle.Visible        = false;
            picReadingPage.Visible = true;

            tmrReadyToGo.Enabled = false;

            // Call the loadBadges() function asynchronously
            await LoadBadgesAsync();

            StartIdle();
            //以下是魔改代码
            if (IsAutoNextOn == true)
            {
                autonextthr();
            }
        }
Ejemplo n.º 7
0
        public async Task LoadBadgesAsync()
        {
            // Settings.Default.myProfileURL = https://steamcommunity.com/id/USER
            // Refresh every time so it will be more stable
            Settings.Default.myProfileURL = SteamProfile.GetSteamUrl();
            var profileLink = Settings.Default.myProfileURL + "/badges";
            var pages       = new List <string>()
            {
                "?p=1"
            };
            var document   = new HtmlDocument();
            int pagesCount = 1;

            try
            {
                // Load Page 1 and check how many pages there are
                var pageURL  = string.Format("{0}/?p={1}", profileLink, 1);
                var response = await CookieClient.GetHttpAsync(pageURL);

                // Response should be empty. User should be unauthorised.
                if (string.IsNullOrEmpty(response))
                {
                    RetryCount++;
                    if (RetryCount == 18)
                    {
                        ResetClientStatus();
                        return;
                    }
                    throw new Exception("");
                }
                document.LoadHtml(response);

                // If user is authenticated, check page count. If user is not authenticated, pages are different.
                var pageNodes = document.DocumentNode.SelectNodes("//a[@class=\"pagelink\"]");
                if (pageNodes != null)
                {
                    pages.AddRange(pageNodes.Select(p => p.Attributes["href"].Value).Distinct());
                    pages = pages.Distinct().ToList();
                }

                string lastpage = pages.Last().ToString().Replace("?p=", "");
                pagesCount = Convert.ToInt32(lastpage);

                // Get all badges from current page
                ProcessBadgesOnPage(document);

                // Load other pages
                for (var i = 2; i <= pagesCount; i++)
                {
                    lblDrops.Text = string.Format(localization.strings.reading_badge_page + " {0}/{1}, " + localization.strings.please_wait, i, pagesCount);

                    // Load Page 2+
                    pageURL  = string.Format("{0}/?p={1}", profileLink, i);
                    response = await CookieClient.GetHttpAsync(pageURL);

                    // Response should be empty. User should be unauthorised.
                    if (string.IsNullOrEmpty(response))
                    {
                        RetryCount++;
                        if (RetryCount == 18)
                        {
                            ResetClientStatus();
                            return;
                        }
                        throw new Exception("");
                    }
                    document.LoadHtml(response);

                    // Get all badges from current page
                    ProcessBadgesOnPage(document);
                }
            }
            catch (Exception ex)
            {
                Logger.Exception(ex, "Badge -> LoadBadgesAsync, for profile = " + Settings.Default.myProfileURL);
                // badge page didn't load
                picReadingPage.Image = null;
                picIdleStatus.Image  = null;
                lblDrops.Text        = localization.strings.badge_didnt_load.Replace("__num__", "10");
                lblIdle.Text         = "";

                // Set the form height
                var graphics = CreateGraphics();
                var scale    = graphics.DpiY * 1.625;
                Height           = Convert.ToInt32(scale);
                ssFooter.Visible = false;

                ReloadCount            = 1;
                tmrBadgeReload.Enabled = true;
                return;
            }

            RetryCount = 0;
            SortBadges(Settings.Default.sort);

            picReadingPage.Visible = false;
            UpdateStateInfo();

            if (CardsRemaining == 0)
            {
                IdleComplete();
            }
        }
        // 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;

            try
            {
                dynamic globalHeader = htmldoc.GetElementById("global_header");
                if (globalHeader != null)
                {
                    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" ||
            if (url.StartsWith("https://steamcommunity.com/login/home/?goto=my/") ||
                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;
                    }
                }

                // Save all of the data to the program settings file, and close this form
                Settings.Default.Save();
                tmrCheck.Enabled = false;
                Close();
            }
        }
Ejemplo n.º 9
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;
                    }
                }

                browserBarVisibility(true); // Display the browser bar (lock, protocol, url)

                // Tell steam client to generate keys to login on browser
                if (Settings.Default.QuickLogin)
                {
                    // Overwrite cookie functions to ignore the auto login cookie checks
                    wbAuth.Document.InvokeScript("eval", new object[] { "function V_SetCookie() {} function V_GetCookie() {}" });
                    wbAuth.Document.InvokeScript("LoginUsingSteamClient", new object[] { "https://steamcommunity.com/" });
                }

                try
                {
                    // Set the "Remember me" checkbox
                    dynamic rememberMeCheckBox = htmldoc.GetElementById("remember_login");
                    if (rememberMeCheckBox != null)
                    {
                        rememberMeCheckBox.Checked = true;
                    }
                }
                catch (Exception)
                {
                }
            }
            // 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
                    else if (cookie.Name == "steamLogin")
                    {
                        Settings.Default.steamLogin   = cookie.Value;
                        Settings.Default.myProfileURL = SteamProfile.GetSteamUrl();
                    }

                    else if (cookie.Name == "steamLoginSecure")
                    {
                        Settings.Default.steamLoginSecure = cookie.Value;
                        Settings.Default.myProfileURL     = SteamProfile.GetSteamUrl();
                    }

                    // Save the "steamparental" cookie"
                    else if (cookie.Name == "steamparental")
                    {
                        Settings.Default.steamparental = cookie.Value;
                    }

                    else if (cookie.Name == "steamRememberLogin")
                    {
                        Settings.Default.steamRememberLogin = cookie.Value;
                    }
                }

                // Save all of the data to the program settings file, and close this form
                Settings.Default.Save();
                Close();
            }
        }