Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- using OpenQA.Selenium;
- using OpenQA.Selenium.Firefox;
- using OpenQA.Selenium.Support.UI;
- namespace Selenium
- {
- /// <summary>
- /// Interaction logic for MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- //
- InitializeComponent();
- }
- private void LogAction(string s)
- {
- //this.Log.Dispatcher.BeginInvoke(
- // () => { },
- // System.Windows.Threading.DispatcherPriority.Background
- // );
- }
- private void RestartDevice()
- {
- //Ust.I.Device = "HID\\VID_3938&PID_1031&COL01";
- //Ust.Zapisz();
- System.Diagnostics.Process process = new System.Diagnostics.Process();
- System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
- ///startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
- startInfo.RedirectStandardError = true;
- startInfo.RedirectStandardOutput = true;
- startInfo.UseShellExecute = false;
- startInfo.FileName = "dmgr.exe";
- startInfo.Arguments = $"restart \"{Ust.I.Device}\"";
- process.StartInfo = startInfo;
- process.Start();
- process.WaitForExit();
- //MessageBox.Show(process.StandardError.ReadToEnd());
- //MessageBox.Show(process.StandardOutput.ReadToEnd());
- //string strCmdText;
- //strCmdText = $"restart \"{Ust.I.Device}\"";
- //System.Diagnostics.Process.Start("dmgr.exe", strCmdText);
- }
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- int ipCounter = 0;
- int generalCounter = 0;
- var users = User.GetUsers();
- LogAction($"Rozpoczęto pracę - pobrano {users.Count} kont");
- foreach (var user in users)
- {
- ChangeIPIfNeeded(ref ipCounter);
- LogAction($"{++generalCounter}/{users.Count} - {user.Login}");
- JoinApp(user);
- }
- //RestartDevice();
- }
- private void ChangeIPIfNeeded(ref int count)
- {
- if(count == Ust.I.IPCount)
- {
- RestartDevice();
- count = 0;
- }
- else
- {
- count++;
- }
- }
- private string JoinApp(User user)
- {
- try
- {
- using (IWebDriver driver = new FirefoxDriver())
- {
- driver.Navigate().GoToUrl("https://www.facebook.com/login.php");
- IWebElement query = driver.FindElement(By.Name("email"));
- query.SendKeys(user.Login);
- query = driver.FindElement(By.Name("pass"));
- query.SendKeys(user.Pass);
- query.Submit();
- driver.Navigate().GoToUrl(Ust.I.AppJoin);
- var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(3));
- query = wait.Until(c => c.FindElement(By.Name("__CONFIRM__")));
- query.Click();
- query = wait.Until(c => c.FindElement(By.XPath("//div[@data-name=\"audience[0][value]\"]")));
- query.Click();
- query = wait.Until(c => c.FindElement(By.XPath("//ul[@class=\"uiMenuInner\"]/li[1]")));
- query.Click();
- query = wait.Until(c => c.FindElement(By.Name("__CONFIRM__")));
- query.Click();
- query = wait.Until(ExpectedConditions.ElementToBeClickable(By.Name("__CONFIRM__")));
- //query = wait.Until(c => c.FindElement(By.Name("__CONFIRM__")));
- query.Click();
- var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(3));
- driver.Navigate().GoToUrl(Ust.I.AppToken);
- if(Ust.I.DoubleRefresh) {
- driver.Navigate().GoToUrl(Ust.I.AppToken);
- }
- query = wait.Until(c => c.FindElement(By.XPath("//form[@action=\"/tools/debug/\"]//input[@type=\"text\"]")));
- Debug.WriteLine(query.GetAttribute("value"));
- return query.GetAttribute("value");
- //data-name="audience[0][value]"
- ////ul[@class="uiMenuInner"]/li[1]
- ////form[@action="/tools/debug/"]//input[@type="text"]
- }
- }
- catch (Exception EX)
- {
- MessageBox.Show(EX.ToString());
- return "";
- }
- }
- }
- public class User
- {
- public string Login { get; set; }
- public string Pass { get; set; }
- public static List<User> GetUsers()
- {
- var users = new List<User>();
- using(var reader = new StreamReader("konta.txt"))
- {
- while(reader.EndOfStream == false)
- {
- var line = reader.ReadLine();
- if (string.IsNullOrEmpty(line)) continue;
- var data = line.Split(new char[] { '|' });
- var user = new User
- {
- Login = data[0],
- Pass = data[1]
- };
- users.Add(user);
- }
- }
- return users;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement