public async void FBLogin(String user, String pass)
        {
            Program.mainForm.btnLogin.Enabled = false;

            if (user == "" || pass == "")
            {
                MessageBox.Show("Điền thông tin đăng nhập!");
                Program.mainForm.btnLogin.Enabled = true;
                return;
            }

            //Program.loadingForm = new LoadingForm();
            //Program.loadingForm.setText("KHỞI TẠO HỆ THỐNG...");
            //Program.loadingForm.Show();
            //Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(() => Program.loadingForm.ShowDialog()));

            //t = new System.Threading.Thread(() => Program.loadingForm.ShowDialog());
            //t.Start(); // LoadingForm.Show()
            // Bật trình duyệt khi Login
            if (driver == null)
            {
                setReady(false, "Đang khởi tạo hệ thống");
                //var profile = new OpenQA.Selenium.Firefox.FirefoxProfile();
                //profile.SetPreference("general.useragent.override", "NokiaC5-00/061.005 (SymbianOS/9.3; U; Series60/3.2 Mozilla/5.0; Profile/MIDP-2.1 Configuration/CLDC-1.1) AppleWebKit/525 (KHTML, like Gecko) Version/3.0 Safari/525 3gpp-gba");
                //profile.SetPreference("webdriver.load.strategy", "unstable");
                //profile.SetPreference("permissions.default.stylesheet", 2);
                //profile.SetPreference("permissions.default.image", 2);
                //profile.AddExtension("App/Firefox/firebug.xpi");
                //profile.SetPreference("dom.ipc.plugins.enabled.libflashplayer.so", "false");
                IEnumerable<int> pidsBefore = Process.GetProcessesByName("chrome").Select(p => p.Id);
                try
                {
                    //this.driver = await Task.Factory.StartNew(() => new OpenQA.Selenium.Firefox.FirefoxDriver(profile));
                    /*
                    OpenQA.Selenium.Firefox.FirefoxBinary firefox = new OpenQA.Selenium.Firefox.FirefoxBinary("App/Firefox/firefox.exe");
                    this.driver = new OpenQA.Selenium.Firefox.FirefoxDriver(firefox, profile);*/
                    var chromeDriverService = OpenQA.Selenium.Chrome.ChromeDriverService.CreateDefaultService(Path.GetDirectoryName(Application.ExecutablePath) + @"\App");
                    chromeDriverService.HideCommandPromptWindow = true;
                    OpenQA.Selenium.Chrome.ChromeOptions chromeDriverOptions = new OpenQA.Selenium.Chrome.ChromeOptions();
                    chromeDriverOptions.AddArgument("--user-agent=NokiaC5-00/061.005 (SymbianOS/9.3; U; Series60/3.2 Mozilla/5.0; Profile/MIDP-2.1 Configuration/CLDC-1.1) AppleWebKit/525 (KHTML, like Gecko) Version/3.0 Safari/525 3gpp-gba"); //Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0
                    chromeDriverOptions.AddArgument("ignore-certificate-errors");
                    chromeDriverOptions.AddArgument("no-sandbox");
                    chromeDriverOptions.AddExtension(Path.GetDirectoryName(Application.ExecutablePath) + @"\App\block.crx");
                    driver = await Task.Factory.StartNew(() => new OpenQA.Selenium.Chrome.ChromeDriver(chromeDriverService, chromeDriverOptions));
                    //Thread.Sleep(1000);
                }
                catch
                {
                    //Program.loadingForm.RequestStop();
                    MessageBox.Show("Thiếu File!?");
                    /*
                    if (MessageBox.Show("Để chạy chương trình, bạn cần cài đặt trình duyệt Mozilla Firefox tích hợp. Cài đặt ngay?", "Cài đặt trình duyệt", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)
                    {
                        MessageBox.Show("Chương trình có thể bị treo trong vài giây tới. Nhấn OK để bắt đầu cài đặt!");
                        // install firefox 34
                        ProcessStartInfo startInfo = new ProcessStartInfo();
                        startInfo.CreateNoWindow = false;
                        startInfo.UseShellExecute = false;
                        startInfo.FileName = "firefox34.exe";
                        startInfo.WindowStyle = ProcessWindowStyle.Hidden;
                        startInfo.Arguments = "-ms";
                        try
                        {
                            using (Process exeProcess = Process.Start(startInfo))
                            {
                                exeProcess.WaitForExit();
                            }
                        }
                        catch { }

                        string[] folders = Directory.GetDirectories(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Mozilla\\Firefox\\Profiles\\", "*.default");
                        string prefs_js = folders[0] + "\\prefs.js";

                        StreamWriter sw;
                        sw = File.AppendText(prefs_js);
                        sw.WriteLine("user_pref('app.update.auto', false);");
                        sw.WriteLine("user_pref('app.update.enabled', false);");
                        sw.Close();

                        MessageBox.Show("Hoàn thành cài đặt! Hãy khởi động lại chương trình!");
                    }*/

                    Exceptions_Handler();
                }
                IEnumerable<int> pidsAfter = Process.GetProcessesByName("chrome").Select(p => p.Id);

                newFirefoxPids = pidsAfter.Except(pidsBefore);

                try
                {
                    foreach (int pid in newFirefoxPids)
                    {
                        int hWnd = Process.GetProcessById(pid).MainWindowHandle.ToInt32();
                        ShowWindow(hWnd, SW_HIDE);
                    }
                }
                catch
                {
                    // newFirefoxPids.Count == 0
                    //Program.loadingForm.RequestStop();
                    MessageBox.Show("Không tìm thấy cửa sổ Trình duyệt!");
                    Exceptions_Handler();
                }

                driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(1));
                driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(10));
                driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(30));
                setReady(true);
            }

            //Program.loadingForm.setText("ĐĂNG NHẬP TÀI KHOẢN FACEBOOK...");
            setReady(false, "Đang đăng nhập");
            await Task.Factory.StartNew(() => Navigate(links["fb_url"]));

            if (await Task.Factory.StartNew(() => driver.FindElementsByName("email").Count) == 0)
            {
                //Program.loadingForm.RequestStop();
                //t.Abort();
                //t.Join();
                MessageBox.Show("Có lỗi với đường truyền mạng hoặc tài khoản facebook của bạn!\nHãy kiểm tra lại");
                Program.mainForm.btnLogin.Enabled = true;
                Program.mainForm.txtUser.Enabled = true;
                Program.mainForm.txtPass.Enabled = true;
                foreach (Control item in Program.mainForm.dgGroups.Controls.OfType<Control>())
                {
                    if (item.Name == "group_loading_gif")
                        Program.mainForm.dgGroups.Controls.Remove(item);
                }
                setReady(true);
                return;
            }
            
            await Task.Factory.StartNew(() => InputValueAdd("email", user));
            await Task.Factory.StartNew(() => InputValueAdd("pass", pass));
            await Task.Factory.StartNew(() => Click("login"));
            /*
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60));
            await Task.Factory.StartNew(() => wait.Until<IWebElement>((d) =>
            {
                return d.FindElement(By.Name("xc_message"));
            }));*/
            //await Task.Factory.StartNew(() => ((IJavaScriptExecutor)driver).ExecuteScript("alert(123)"));
            driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(300));
            string after_login_url = await Task.Factory.StartNew(() => driver.Url);
            driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(30));

            check_after_login:
            if (after_login_url.Contains("home.php") || after_login_url.Contains("phoneacquire"))
            {
                Program.mainForm.btnLogin.Text = "Đăng nhập thành công!";
                Program.mainForm.AcceptButton = null;
                Program.mainForm.btnPost.Enabled = true;
                Program.mainForm.btnInvite.Enabled = true;
                Program.mainForm.btnGroupSearch.Enabled = true;
                Program.mainForm.btnGroupJoin.Enabled = true;
                Program.mainForm.btnPMImportFriends.Enabled = true;
                Program.mainForm.btnPM.Enabled = true;
                Program.mainForm.btnPMSendFrRequests.Enabled = true;
                Program.mainForm.btnInteractionsFollow.Enabled = true;
                Program.mainForm.btnInteractionsPoke.Enabled = true;
                Program.mainForm.btnInteractionsLike.Enabled = true;
                Program.mainForm.btnPMImportProfile.Enabled = true;
                Program.mainForm.btnPMImportGroup.Enabled = true;
                Program.mainForm.btnCommentImportComment.Enabled = true;
                Program.mainForm.btnPostImportGroups.Enabled = true;
                Program.mainForm.btnGroupImportFriends.Enabled = true;
                Program.mainForm.btnCommentScan.Enabled = true;
                Program.mainForm.btnFanpageComment.Enabled = true;
                Program.mainForm.btnFanpageGroupPost.Enabled = true;
                Program.mainForm.btnEventInviteFriends.Enabled = true;
                Program.mainForm.btnFanpageSeeder.Enabled = true;
                Program.mainForm.btnFanpageInviteFriends.Enabled = true;
                Program.mainForm.btnFanpageLike.Enabled = true;
                Program.mainForm.btnGraphSearch.Enabled = true;
                
                var photos = await Task.Factory.StartNew(() => driver.FindElementsByXPath("//a[contains(@href, '?v=photos')]"));
                if (photos.Count > 0)
                {
                    String href = photos[0].GetAttribute("href");
                    Match match = Regex.Match(href, @".com\/([A-Za-z0-9\-\.]+)\?v\=photos", RegexOptions.None);
                    if (match.Success)
                    {
                        user_id = match.Groups[1].Value;
                    }
                }

                var nodes = await Task.Factory.StartNew(() => driver.FindElementsByXPath("//img[contains(@src, 'fbcdn-profile-a.akamaihd.net')]"));
                if (nodes.Count > 0)
                {
                    Program.mainForm.lblUsername.Text = nodes[0].GetAttribute("alt");
                }

                try
                {
                    user_id_img = user_id;
                    await Task.Factory.StartNew(() =>
                    {
                        try
                        {
                            user_id_img = driver.FindElementByName("target").GetAttribute("value");
                        }
                        catch { }
                    });

                    Program.mainForm.pbAvatar.WaitOnLoad = false;
                    Program.mainForm.pbAvatar.LoadAsync(links["facebook_graph"] + "/" + user_id_img + "/picture");
                    Program.mainForm.lblViewProfile.Text = "https://facebook.com/" + user_id_img;
                }
                catch { }
                
                //Program.mainForm.Focus();
                //Program.loadingForm.setText("ĐĂNG NHẬP THÀNH CÔNG! ĐANG TẢI DANH SÁCH NHÓM...");
                Program.mainForm.lblStatus.Text = "Tải danh sách nhóm...";
                Program.mainForm.dgGroups.Rows.Clear();
                if (Program.mainForm.cbGroupReload.Checked)
                {
                    try
                    {
                        DataSet DS = new DataSet();
                        DS.ReadXml(RemoveSpecialCharacters(user_id_img) + "_groups.xml");

                        bool empty = true;

                        foreach (DataRow dr in DS.Tables[0].Rows)
                        {
                            Program.mainForm.dgGroups.Rows.Add(dr[0], dr[1], dr[2], dr[3]);
                            await TaskEx.Delay(1);
                            if (dr[3].ToString() == "1") empty = false;
                        }

                        if (empty)
                        {
                            foreach (DataGridViewRow row in Program.mainForm.dgGroups.Rows)
                            {
                                DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)row.Cells[3];
                                chk.Value = 1;
                            }
                        }
                    }
                    catch { }
                }

                if (Program.mainForm.dgGroups.RowCount == 0) await getGroups();
                else
                {
                    //Program.loadingForm.RequestStop();
                    //t.Abort();
                    //t.Join();
                    Program.mainForm.lblProgress.Text = "0/" + Program.mainForm.dgGroups.Rows.Count;
                    setReady(true, "Số lượng nhóm: " + Program.mainForm.dgGroups.Rows.Count);
                }

                Program.mainForm.btnLogin.Text = "Đăng xuất";
                Program.mainForm.btnLogin.Enabled = true;

                foreach (Control item in Program.mainForm.dgGroups.Controls.OfType<Control>())
                {
                    if (item.Name == "group_loading_gif")
                        Program.mainForm.dgGroups.Controls.Remove(item);
                }
            }
            else
            {
                if (getUrl().Contains("home.php"))
                {
                    goto check_after_login; // check again, just in case 100ms is not enough
                }

                Program.mainForm.txtUser.Enabled = true;
                Program.mainForm.txtPass.Enabled = true;
                foreach (Control item in Program.mainForm.dgGroups.Controls.OfType<Control>())
                {
                    if (item.Name == "group_loading_gif")
                        Program.mainForm.dgGroups.Controls.Remove(item);
                }
                //Program.loadingForm.RequestStop();
                //t.Abort();
                //t.Join();
                if (getUrl().Contains("checkpoint"))
                    MessageBox.Show("Hãy vô hiệu hóa bảo mật tài khoản trước khi sử dụng AUTO!");
                
                MessageBox.Show("Kiểm tra lại thông tin đăng nhập!\nNếu bạn chắc chắn thông tin đăng nhập là đúng,\nhãy đăng nhập lại tài khoản trên trình duyệt trước khi tiếp tục!");
                Program.mainForm.btnLogin.Enabled = true;
                setReady(true);
                return;
            }
            // await Task.Factory.StartNew(() => new WebDriverWait(driver, TimeSpan.FromSeconds(10))); // Chờ tải xong trang
        }