Exemple #1
0
        private void buttonAddAccount_Click(object sender, EventArgs e)
        {
            SaveAccountWindow window = new SaveAccountWindow();

            window.FormClosing += Action_FormClosing;
            ShowWindow(window);
        }
Exemple #2
0
        private void addAnAccountToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveAccountWindow window = new SaveAccountWindow();

            window.FormClosing += Action_FormClosing;
            ShowWindow(window);
        }
Exemple #3
0
        private void listViewAccounts_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            ListViewHitTestInfo info   = listViewAccounts.HitTest(e.X, e.Y);
            ListViewItem        item   = info.Item;
            SaveAccountWindow   window = new SaveAccountWindow(item.Tag as AccountModel);

            window.FormClosing += Action_FormClosing;
            ShowWindow(window);
        }
Exemple #4
0
        private void buttonEditAccount_Click(object sender, EventArgs e)
        {
            AccountModel model = GetSelectedAccount(listViewAccounts);

            if (model == null)
            {
                return;
            }

            SaveAccountWindow window = new SaveAccountWindow(model);

            window.FormClosing += Action_FormClosing;
            ShowWindow(window);
        }
        private void Work()
        {
            if (driver != null)
            {
                driver.Quit();
                driver = null;
            }

            var options = new ChromeOptions();

            options.SetLoggingPreference(LogType_Performance, LogLevel.All);
            options.AddArgument("disable-gpu");
            options.AddArgument("disable-infobars");
            options.AddArgument("--disable-extensions");
            //options.AddUserProfilePreference("profile.default_content_settings", 2);
            //options.AddUserProfilePreference("profile.default_content_setting_values", 2);

            //options.AddArgument("-homepage \"" + StartUpURL + "\"");
            options.AddArgument("user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6)" +
                                "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36"); //Not bot

            var service = ChromeDriverService.CreateDefaultService();

            service.HideCommandPromptWindow = true;

            try
            {
                driver = new ChromeDriver(service, options);
                driver.Navigate().GoToUrl(StartUpURL);
                this.Ready = true;
            }
            catch (Exception e)
            {
                if (!this.IsAborted)
                {
                    Console.WriteLine("[Exception] Hooker-CrawlingScripts-LoadChromeDriver: " + e.Message);
                }
                Process[] chromeDriverProcesses = Process.GetProcessesByName("chromedriver");
                foreach (var chromeDriverProcess in chromeDriverProcesses)
                {
                    try
                    {
                        if (chromeDriverProcess.MainModule.FileName.StartsWith(
                                System.AppDomain.CurrentDomain.BaseDirectory))
                        {
                            chromeDriverProcess.Kill();
                        }
                    }
                    catch (Exception _e)
                    {
                        if (!this.IsAborted)
                        {
                            Console.WriteLine("[Exception] Hooker-CrawlingScripts-Kill: " + _e.Message);
                        }
                    }
                }
                System.Environment.Exit(-1);
            }
            //Do login
            try
            {
                string account_id;
                if (SaveAccountWindow.GetSavedAccount_ID(out account_id))
                {
                    //Loading..?
                    IWebElement loginFormElement = null;
                    IWebElement idInput          = null;
                    IWebElement pwInput          = null;
                    var         started          = System.DateTime.Now;
                    do
                    {
                        loginFormElement = driver.FindElementByXPathOrNull("/html/body/div[2]");
                        idInput          = FindElementWithXPathDict(XPathKey_Login_IDInputBox);
                        pwInput          = FindElementWithXPathDict(XPathKey_Login_PWInputBox);
                        if ((System.DateTime.Now - started).TotalSeconds > LoginFormWaitTimeout)
                        {
                            throw new Exception("Timeout");
                        }
                        if (this.IsAborted)
                        {
                            throw new Exception("Aborted");
                        }
                    } while (loginFormElement == null || idInput == null || pwInput == null);
                    Console.WriteLine("[Log] Loginform wait completed: {0}", (System.DateTime.Now - started).TotalSeconds);

                    idInput.SendKeys(account_id);
                    account_id = null;

                    string account_pw;
                    if (SaveAccountWindow.GetSavedAccount_Password(out account_pw))
                    {
                        pwInput.SendKeys(account_pw);
                        account_pw = null;

                        var loginButton = FindElementWithXPathDict(XPathKey_Login_LoginButton);
                        if (loginButton != null)
                        {
                            loginButton.Click();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                if (!this.IsAborted)
                {
                    Console.WriteLine("[Exception] Hooker-AutoLogin: "******"message"];
                        var method  = message["method"].Value <string>();
                        #endregion

                        if (string.Equals(method, "Network.webSocketFrameReceived"))
                        {
                            var response = message["params"]["response"];
                            if (response.HasValues)
                            {
                                var payloadData = JToken.Parse(response["payloadData"].Value <string>());
                                ParsePayloadData(payloadData);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    if (!this.IsAborted)
                    {
                        Console.WriteLine("[Exception] Hooker-CrawlingScripts: " + e.Message);
                    }
                }
            }

            //Dispose
            if (driver != null)
            {
                driver.Quit();
                driver = null;
            }
            crawlingThread = null;
        }