using Newtonsoft.Json; using OpenQA.Selenium; using OpenQA.Selenium.Chrome; using System; using System.Collections; using System.Collections.Generic; using System.Drawing; using System.IO; using System.Linq; using System.Net; using System.Runtime.InteropServices; using System.Security.Cryptography; using System.Text; using System.Threading; namespace ConsoleApp1 { class Program { //hide console [DllImport("kernel32.dll")] static extern IntPtr GetConsoleWindow(); [DllImport("user32.dll")] static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); const int SW_HIDE = 0; static string json10 = File.ReadAllText(@"findElement.json"); static dynamic path = JsonConvert.DeserializeObject(json10); static Random rnd = new Random(); static ChromeDriver driver; static string randomComm() { string json = File.ReadAllText(@"config/data.json"); dynamic data = JsonConvert.DeserializeObject(json); string json1 = File.ReadAllText(@"config/commentData.json"); dynamic comment = JsonConvert.DeserializeObject(json1); int i = 0; Random rnd = new Random(); string x = ""; int lastComment = data["lastComment"]; while (x.Length < 2) { string json2 = File.ReadAllText(@"config/data.json"); dynamic data2 = JsonConvert.DeserializeObject(json2); string commNumbers = data2["commentNumbers"]; int randomNumber = rnd.Next(1, Int32.Parse(commNumbers)); x = comment["comment_id_" + randomNumber]; if (x.Length != 0 && lastComment != randomNumber) { data2["lastComment"] = randomNumber; string output2 = JsonConvert.SerializeObject(data2, Formatting.Indented); File.WriteAllText(@"config/data.json", output2); Console.WriteLine(x); return x; } i++; } return "none"; } static void clickElementByXpath(string name) { bool x = false; while (x != true) { if (x == true) { IWebElement y = driver.FindElement(By.XPath(name)); y.Click(); Console.WriteLine("Dostepny"); } else { try { IWebElement y = driver.FindElement(By.XPath(name)); y.Click(); x = true; Console.WriteLine("Dostepny"); } catch { Console.WriteLine("Nie dostepny"); Thread.Sleep(200); } } } Thread.Sleep(500); } static void sendKeysByName(string name, string message) { bool x = false; while (x != true) { if (x == true) { IWebElement y = driver.FindElement(By.Name(name)); y.SendKeys(message); Console.WriteLine("Dostepny"); } else { try { IWebElement y = driver.FindElement(By.Name(name)); y.SendKeys(message); ; x = true; Console.WriteLine("Dostepny"); } catch { Console.WriteLine("Nie dostepny"); Thread.Sleep(200); } } } Thread.Sleep(500); } static bool clickElementByXpath2(string name) { int z = 0; bool x = false; while (x != true) { if (x == true) { IWebElement y = driver.FindElement(By.XPath(name)); Console.WriteLine("Dostepny"); return false; } else { try { IWebElement y = driver.FindElement(By.XPath(name)); y.Click(); x = true; Console.WriteLine("Dostepny"); return false; } catch { Console.WriteLine("Nie dostepny"); Thread.Sleep(200); z++; } } if (z >= 15) { return true; } } Thread.Sleep(500); return true; } static void clickElementByClassName(string name) { bool x = false; while (x != true) { if (x == true) { IWebElement y = driver.FindElement(By.ClassName(name)); y.Click(); Console.WriteLine("Dostepny"); } else { try { IWebElement y = driver.FindElement(By.ClassName(name)); y.Click(); x = true; Console.WriteLine("Dostepny"); } catch { Console.WriteLine("Nie dostepny"); Thread.Sleep(200); } } } Thread.Sleep(500); } static void sendKeysByXpath(string name, string message) { bool x = false; while (x != true) { if (x == true) { IWebElement y = driver.FindElement(By.XPath(name)); y.SendKeys(message); Console.WriteLine("Dostepny"); } else { try { IWebElement y = driver.FindElement(By.XPath(name)); y.SendKeys(message); ; x = true; Console.WriteLine("Dostepny"); } catch { Console.WriteLine("Nie dostepny"); Thread.Sleep(200); } } } Thread.Sleep(500); } static void sendKeysById(string name, string message) { bool x = false; while (x != true) { if (x == true) { IWebElement y = driver.FindElement(By.Id(name)); y.SendKeys(message); Console.WriteLine("Dostepny"); } else { try { IWebElement y = driver.FindElement(By.Id(name)); y.SendKeys(message); ; x = true; Console.WriteLine("Dostepny"); } catch { Console.WriteLine("Nie dostepny"); Thread.Sleep(200); } } } Thread.Sleep(500); } static string getAttributeByXpath(string name, string kindfOfAttribute) { bool x = false; while (x != true) { if (x == true) { string y = driver.FindElement(By.XPath(name)).GetAttribute(kindfOfAttribute); Console.WriteLine("Dostepny"); return y; } else { try { string y = driver.FindElement(By.XPath(name)).GetAttribute(kindfOfAttribute); x = true; Console.WriteLine("Dostepny"); return y; } catch { Console.WriteLine("Nie dostepny"); Thread.Sleep(200); } } } Thread.Sleep(500); return "done"; } static string getAttributeByCssSelector(string name, string kindfOfAttribute) { bool x = false; while (x != true) { if (x == true) { string y = driver.FindElement(By.CssSelector(name)).GetAttribute(kindfOfAttribute); Console.WriteLine("Dostepny"); return y; } else { try { string y = driver.FindElement(By.CssSelector(name)).GetAttribute(kindfOfAttribute); x = true; Console.WriteLine("Dostepny"); return y; } catch { Console.WriteLine("Nie dostepny"); Thread.Sleep(200); } } } Thread.Sleep(500); return "done"; } static string getAttributeByCssSelector2(string name, string kindfOfAttribute) { int z = 0; bool x = false; while (x != true) { if (x == true) { string y = driver.FindElement(By.CssSelector(name)).GetAttribute(kindfOfAttribute); Console.WriteLine("Dostepny"); return y; } else { try { string y = driver.FindElement(By.CssSelector(name)).GetAttribute(kindfOfAttribute); x = true; Console.WriteLine("Dostepny"); return y; } catch { z++; Console.WriteLine("Nie dostepny"); Thread.Sleep(200); } } if (z >= 5) { return "false"; } } Thread.Sleep(500); return "done"; } static string checkElementByXpath(string name) { int z = 0; bool x = false; while (x != true) { if (x == true) { IWebElement y = driver.FindElement(By.XPath(name)); Console.WriteLine("Dostepny"); return "true"; } else { try { IWebElement y = driver.FindElement(By.XPath(name)); x = true; Console.WriteLine("Dostepny"); return "true"; } catch { Console.WriteLine("Nie dostepny"); Thread.Sleep(200); z++; } } if (z >= 10) { return "false"; } } Thread.Sleep(500); return "done"; } static string checkElementByXpath2(string name) { int z = 0; bool x = false; while (x != true) { if (x == true) { IWebElement y = driver.FindElement(By.XPath(name)); Console.WriteLine("Dostepny"); return "false"; } else { try { IWebElement y = driver.FindElement(By.XPath(name)); x = true; Console.WriteLine("Dostepny"); return "false"; } catch { Console.WriteLine("Nie dostepny"); Thread.Sleep(200); z++; } } if (z >= 2) { return "true"; } } Thread.Sleep(500); return "done"; } static string checkElementByXpath3(string name) { int z = 0; bool x = false; while (x != true) { if (x == true) { IWebElement y = driver.FindElement(By.XPath(name)); Console.WriteLine("Dostepny"); return "false"; } else { try { IWebElement y = driver.FindElement(By.XPath(name)); x = true; Console.WriteLine("Dostepny"); return "false"; } catch { Console.WriteLine("Nie dostepny"); Thread.Sleep(200); z++; } } if (z >= 20) { return "true"; } } Thread.Sleep(500); return "done"; } static void useRandomTimeSafe() { Random rnd = new Random(); int time = rnd.Next(4000, 8000); Thread.Sleep(time); } static void useRandomTimeFast() { Random rnd = new Random(); int time = rnd.Next(1433, 1833); Thread.Sleep(time); } static void sendSmsCode() { int smsCode = 0; while (smsCode == 0) { string json = File.ReadAllText(@"codeSms.json"); dynamic code = JsonConvert.DeserializeObject(json); smsCode = code["code"]; if (smsCode != 0) { Thread.Sleep(1000); try { IWebElement panel = driver.FindElement(By.XPath("//input[@class='_2hvTZ pexuQ zyHYP']")); panel.SendKeys(smsCode.ToString()); } catch { string smsCodeInput = path["smsCodeInput"]; sendKeysByXpath(smsCodeInput, smsCode.ToString()); } string smsCodeAcceptButton = path["smsCodeAcceptButton"]; clickElementByXpath(smsCodeAcceptButton); Thread.Sleep(2000); int codeError = driver.FindElements(By.Id("twoFactorErrorAlert")).Count(); if (codeError == 0) { code["code"] = 0; code["codeError"] = false; string output = JsonConvert.SerializeObject(code, Formatting.Indented); File.WriteAllText(@"codeSms.json", output); } else { code["code"] = 0; code["codeError"] = true; string output = JsonConvert.SerializeObject(code, Formatting.Indented); File.WriteAllText(@"codeSms.json", output); Thread.Sleep(2000); driver.Close(); driver.Quit(); Environment.Exit(0); } } else { Thread.Sleep(10000); } } } static void webBrowser() { /* var chromeOptions = new ChromeOptions(); ChromeDriverService service = ChromeDriverService.CreateDefaultService(); service.HideCommandPromptWindow = true; chromeOptions.AddAdditionalCapability("useAutomationExtension", false); chromeOptions.AddExcludedArgument("enable-automation"); chromeOptions.AddArguments("--incognito"); chromeOptions.AddArguments("network.cookie.cookieBehavior"); chromeOptions.AddArgument("headless"); */ ChromeDriverService service = ChromeDriverService.CreateDefaultService(); service.HideCommandPromptWindow = true; var options = new ChromeOptions(); //options.AddArgument("--window-position=-32000,-32000"); options.AddExcludedArgument("enable-automation"); options.AddArguments("incognito"); options.AddAdditionalCapability("useAutomationExtension", false); options.AddArgument("headless"); driver = new ChromeDriver(service, options); driver.Navigate().GoToUrl("https://www.instagram.com/accounts/login/?hl=pl"); Thread.Sleep(5000); driver.Manage().Window.Size = new Size(1200, 600); } static void loginAsInstagram() { string json2 = File.ReadAllText(@"neutralData.json"); dynamic neutralData = JsonConvert.DeserializeObject(json2); string email = neutralData["email"]; string password = neutralData["password"]; string instagramEmail = path["instagramEmail"]; sendKeysByName(instagramEmail, Decrypt(email)); Thread.Sleep(1000); string instagramPassword = path["instagramPassword"]; sendKeysByName(instagramPassword, Decrypt(password)); string instagramLoginButton = path["instagramLoginButton"]; clickElementByXpath(instagramLoginButton); string smsPanel = path["smsPanel"]; bool smsCode = clickElementByXpath2(smsPanel); // check sms verify if (smsCode == true) { string json = File.ReadAllText(@"neutralData.json"); dynamic jsonObj = JsonConvert.DeserializeObject(json); jsonObj["smsLogin"] = "ok"; string output = JsonConvert.SerializeObject(jsonObj, Formatting.Indented); File.WriteAllText(@"neutralData.json", output); } if (smsCode == false) { string json = File.ReadAllText(@"neutralData.json"); dynamic jsonObj = JsonConvert.DeserializeObject(json); jsonObj["smsLogin"] = "error"; string output = JsonConvert.SerializeObject(jsonObj, Formatting.Indented); File.WriteAllText(@"neutralData.json", output); Thread.Sleep(2000); sendSmsCode(); } string instagramLoginError = path["instagramLoginError"]; bool error = clickElementByXpath2(instagramLoginError); if (error == true) { string json = File.ReadAllText(@"neutralData.json"); dynamic jsonObj = JsonConvert.DeserializeObject(json); jsonObj["errorLogin"] = "ok"; string output = JsonConvert.SerializeObject(jsonObj, Formatting.Indented); File.WriteAllText(@"neutralData.json", output); string json1 = File.ReadAllText(@"neutralData.json"); dynamic neutral = JsonConvert.DeserializeObject(json1); neutral["loginSucces"] = true; string output2 = JsonConvert.SerializeObject(neutral, Formatting.Indented); File.WriteAllText(@"neutralData.json", output2); } if (error == false) { string json = File.ReadAllText(@"neutralData.json"); dynamic jsonObj = JsonConvert.DeserializeObject(json); jsonObj["errorLogin"] = "error"; string output = JsonConvert.SerializeObject(jsonObj, Formatting.Indented); File.WriteAllText(@"neutralData.json", output); string json1 = File.ReadAllText(@"neutralData.json"); dynamic neutral = JsonConvert.DeserializeObject(json1); neutral["tryToLogin"] = false; string output2 = JsonConvert.SerializeObject(neutral, Formatting.Indented); File.WriteAllText(@"neutralData.json", output2); Thread.Sleep(2000); } } static void loginAsFacebook() { string json2 = File.ReadAllText(@"neutralData.json"); dynamic neutralData = JsonConvert.DeserializeObject(json2); string facebookLoginPanel = path["facebookLoginPanel"]; clickElementByXpath(facebookLoginPanel); string email = neutralData["email"]; string password = neutralData["password"]; string facebookEmail = path["facebookEmail"]; sendKeysById(facebookEmail, Decrypt(email)); Thread.Sleep(1000); string facebookPassword = path["facebookPassword"]; sendKeysById(facebookPassword, Decrypt(password)); string facebookLoginButton = path["facebookLoginButton"]; clickElementByXpath(facebookLoginButton); ///////////////////error find string smsPanel = path["smsPanel"]; bool smsCode = clickElementByXpath2(smsPanel); // check sms verify if (smsCode == true) { string json = File.ReadAllText(@"neutralData.json"); dynamic jsonObj = JsonConvert.DeserializeObject(json); jsonObj["smsLogin"] = "ok"; string output = JsonConvert.SerializeObject(jsonObj, Formatting.Indented); File.WriteAllText(@"neutralData.json", output); } if (smsCode == false) { string json = File.ReadAllText(@"neutralData.json"); dynamic jsonObj = JsonConvert.DeserializeObject(json); jsonObj["smsLogin"] = "error"; string output = JsonConvert.SerializeObject(jsonObj, Formatting.Indented); File.WriteAllText(@"neutralData.json", output); Thread.Sleep(2000); sendSmsCode(); } string facebookLoginError = path["facebookLoginError"]; bool error = clickElementByXpath2(facebookLoginError); if (error == true) { string json = File.ReadAllText(@"neutralData.json"); dynamic jsonObj = JsonConvert.DeserializeObject(json); jsonObj["errorLogin"] = "ok"; string output = JsonConvert.SerializeObject(jsonObj, Formatting.Indented); File.WriteAllText(@"neutralData.json", output); string json1 = File.ReadAllText(@"neutralData.json"); dynamic neutral = JsonConvert.DeserializeObject(json1); neutral["loginSucces"] = true; string output2 = JsonConvert.SerializeObject(neutral, Formatting.Indented); File.WriteAllText(@"neutralData.json", output2); } if (error == false) { string json = File.ReadAllText(@"neutralData.json"); dynamic jsonObj = JsonConvert.DeserializeObject(json); jsonObj["errorLogin"] = "error"; string output = JsonConvert.SerializeObject(jsonObj, Formatting.Indented); File.WriteAllText(@"neutralData.json", output); string json1 = File.ReadAllText(@"neutralData.json"); dynamic neutral = JsonConvert.DeserializeObject(json1); neutral["tryToLogin"] = false; string output2 = JsonConvert.SerializeObject(neutral, Formatting.Indented); File.WriteAllText(@"neutralData.json", output2); Thread.Sleep(2000); } string acceptFacbeookLoginAccount = path["acceptFacbeookLoginAccount"]; string statusAcceptFbButton = checkElementByXpath2(acceptFacbeookLoginAccount); if (statusAcceptFbButton.Equals("false")) { clickElementByXpath(acceptFacbeookLoginAccount); } } static void currentAction(string action) { string json2 = File.ReadAllText(@"action.json"); dynamic dat2 = JsonConvert.DeserializeObject(json2); dat2["action"] = action; string output = JsonConvert.SerializeObject(dat2, Formatting.Indented); File.WriteAllText(@"action.json", output); } static void currentLoginStatus(int status) { string json2 = File.ReadAllText(@"neutralData.json"); dynamic dat2 = JsonConvert.DeserializeObject(json2); dat2["loginProgress"] = status; string output = JsonConvert.SerializeObject(dat2, Formatting.Indented); File.WriteAllText(@"neutralData.json", output); } static void isLoginReady(bool status) { string json2 = File.ReadAllText(@"neutralData.json"); dynamic dat2 = JsonConvert.DeserializeObject(json2); dat2["isLoginScreenReady"] = status; string output = JsonConvert.SerializeObject(dat2, Formatting.Indented); File.WriteAllText(@"neutralData.json", output); } static int dayLike() { string json2 = File.ReadAllText(@"config/likeDay.json"); dynamic like = JsonConvert.DeserializeObject(json2); try { string date = DateTime.Now.ToString("dd.MM.yyy"); string list = like[date]; string likeBeforeS = like[date]; int likeBefore = Int32.Parse(likeBeforeS); return likeBefore; } catch { return 0; } } static int dayProfileLike() { string json2 = File.ReadAllText(@"config/profileLikeDay.json"); dynamic like = JsonConvert.DeserializeObject(json2); try { string date = DateTime.Now.ToString("dd.MM.yyy"); string list = like[date]; string likeBeforeS = like[date]; int likeBefore = Int32.Parse(likeBeforeS); return likeBefore; } catch { return 0; } } static int dayComm() { string json2 = File.ReadAllText(@"config/commDay.json"); dynamic comm = JsonConvert.DeserializeObject(json2); try { string date = DateTime.Now.ToString("dd.MM.yyy"); string list = comm[date]; string likeBeforeS = comm[date]; int likeBefore = Int32.Parse(likeBeforeS); return likeBefore; } catch { return 0; } } static void Main(string[] args) { //hide console //var handle = GetConsoleWindow(); // ShowWindow(handle, SW_HIDE); for(int i = 0; i <= 20; i++) { randomComm(); } currentAction(" "); currentLoginStatus(0); isLoginReady(false); string json = File.ReadAllText(@"codeSms.json"); dynamic code = JsonConvert.DeserializeObject(json); code["codeError"] = false; string output1 = JsonConvert.SerializeObject(code, Formatting.Indented); File.WriteAllText(@"codeSms.json", output1); string json1 = File.ReadAllText(@"neutralData.json"); dynamic neutral = JsonConvert.DeserializeObject(json1); neutral["neutralData"] = true; neutral["tryToLogin"] = false; neutral["runTheProgramm"] = false; neutral["loginSucces"] = false; neutral["loginStatus"] = false; neutral["errorLogin"] = "ok"; neutral["smsLogin"] = "ok"; neutral["exitTheProgram"] = false; string output2 = JsonConvert.SerializeObject(neutral, Formatting.Indented); File.WriteAllText(@"neutralData.json", output2); Thread.Sleep(4000); List functions = new List(); functions.Add(getPostAndFollowesNumber); functions.Add(accountAge); functions.Add(kindOfProgramm); functions.Add(getPostAndFollowesNumber); functions.Add(likePostFromLink); functions.Add(getPostAndFollowesNumber); if (codeCheck() == true) { currentAction("Start working"); webBrowser(); logIn(); getUserName(); bool exitProgram = neutral["exitTheProgram"]; while (!exitProgram) { while (waitToStartTheProgramm()) { //clear json file and stats File.WriteAllText(@"config/linkToLike.json", "{}"); string json5 = File.ReadAllText(@"config/data.json"); dynamic jsonObj5 = JsonConvert.DeserializeObject(json5); jsonObj5["currentLike"] = 0.ToString(); jsonObj5["currentFollow"] = 0.ToString(); jsonObj5["currentComment"] = 0.ToString(); jsonObj5["likesInAccountFromLinks"] = 0.ToString(); jsonObj5["commError"] = 0.ToString(); jsonObj5["igError"] = "false"; jsonObj5["hashtagError"] = false; string output = JsonConvert.SerializeObject(jsonObj5, Formatting.Indented); File.WriteAllText(@"config/data.json", output); Thread.Sleep(1000); foreach (Action func in functions) { string json50 = File.ReadAllText(@"neutralData.json"); dynamic neutral1 = JsonConvert.DeserializeObject(json50); bool x = neutral1["exitTheProgram"]; if (x == true) break; func(); } //getPostAndFollowesNumber(); // accountAge(); //kindOfProgramm(); //getPostAndFollowesNumber(); //likePostFromLink(); //getPostAndFollowesNumber(); currentAction("Work finished"); Thread.Sleep(3000); currentAction(" "); neutral["runTheProgramm"] = false; neutral["exitTheProgram"] = false; string output500 = JsonConvert.SerializeObject(neutral, Formatting.Indented); File.WriteAllText(@"neutralData.json", output500); } } } else { Console.Clear(); Console.WriteLine("Wrong verify code, buy full version or contact with suport"); Console.WriteLine((DateTime.Now.DayOfYear * 2137 * DateTime.DaysInMonth(2001, 2))); currentAction(" "); Environment.Exit(0); } neutral["neutralData"] = false; string output3 = JsonConvert.SerializeObject(neutral, Formatting.Indented); File.WriteAllText(@"neutralData.json", output3); Console.WriteLine((DateTime.Now.DayOfYear * 2137 * DateTime.DaysInMonth(2001, 2))); driver.Close(); driver.Quit(); Thread.Sleep(1000); currentAction(" "); currentLoginStatus(0); isLoginReady(false); Environment.Exit(0); } static void hashatagError() { Thread.Sleep(2000); string noHastag = path["noHastag"]; int hashtag = driver.FindElements(By.XPath(noHastag)).Count(); if (hashtag != 0) { string json5 = File.ReadAllText(@"config/data.json"); dynamic jsonObj5 = JsonConvert.DeserializeObject(json5); jsonObj5["hashtagError"] = true; string output = JsonConvert.SerializeObject(jsonObj5, Formatting.Indented); File.WriteAllText(@"config/data.json", output); Thread.Sleep(2000); driver.Close(); driver.Quit(); Environment.Exit(0); } } static void waitToLogin() { bool x = false; while (x == false) { string json1 = File.ReadAllText(@"neutralData.json"); dynamic neutral = JsonConvert.DeserializeObject(json1); x = neutral["tryToLogin"]; if (x == false) { Thread.Sleep(4000); } } } static bool waitToStartTheProgramm() { bool x = false; while (x == false) { string json1 = File.ReadAllText(@"neutralData.json"); dynamic neutral = JsonConvert.DeserializeObject(json1); x = neutral["runTheProgramm"]; if (x == false) { Thread.Sleep(4000); } if (x == true) { return true; } } return false; } static void logIn() { bool loginSucces = false; while (loginSucces == false) { isLoginReady(true); waitToLogin(); string json = File.ReadAllText(@"neutralData.json"); dynamic neutralData = JsonConvert.DeserializeObject(json); driver.Navigate().GoToUrl("https://www.instagram.com/accounts/login/?hl=pl"); currentLoginStatus(1); currentAction("Try To Log In"); string kindOflogin = neutralData["kindOfLogin"]; if (kindOflogin.Equals("instagram")) { loginAsInstagram(); Thread.Sleep(1500); } if (kindOflogin.Equals("facebook")) { loginAsFacebook(); Thread.Sleep(1000); } string json1 = File.ReadAllText(@"neutralData.json"); dynamic neutral = JsonConvert.DeserializeObject(json1); loginSucces = neutral["loginSucces"]; Thread.Sleep(300); } currentLoginStatus(2); currentAction("Login Succes"); string json2 = File.ReadAllText(@"neutralData.json"); dynamic neutral1 = JsonConvert.DeserializeObject(json2); neutral1["loginStatus"] = true; string output2 = JsonConvert.SerializeObject(neutral1, Formatting.Indented); File.WriteAllText(@"neutralData.json", output2); Thread.Sleep(300); } static void startFastProgramm() { string json40 = File.ReadAllText(@"config/data.json"); dynamic data = JsonConvert.DeserializeObject(json40); IJavaScriptExecutor js = (IJavaScriptExecutor)driver; int linkNumber = 1; int currentLike = 0; int currentFollow = 0; int currentComment = 0; string currentFollowId = data["currentFollowId"]; int currentIdNumberFollow = Int32.Parse(currentFollowId); string currentLikeId = data["currentLikeId"]; int currentIdNumberLike = Int32.Parse(currentLikeId); string currentCommId = data["currentCommId"]; int currentIdNumberComm = Int32.Parse(currentCommId); int commError = 0; string json2 = File.ReadAllText(@"config/data.json"); dynamic jsonObj2 = JsonConvert.DeserializeObject(json2); jsonObj2["commError"] = commError.ToString(); string output2 = JsonConvert.SerializeObject(jsonObj2, Formatting.Indented); File.WriteAllText(@"config/data.json", output2); string tag = data["tag"]; if (tag.Length > 20) { driver.Navigate().GoToUrl(tag); } else { driver.Navigate().GoToUrl("https://www.instagram.com/explore/tags/" + tag); } Thread.Sleep(2000); js.ExecuteScript("window.scrollTo(0, 500)"); Thread.Sleep(1000); int likeBefore = dayLike(); int commBefore = dayComm(); hashatagError(); string jsonUserName = File.ReadAllText(@"neutralData.json"); dynamic neutral = JsonConvert.DeserializeObject(jsonUserName); string userNick = neutral["instagramUserName"]; string clickFirstPost = path["clickFirstPost"]; clickElementByXpath(clickFirstPost); string postNumber = data["postNumber"]; currentAction("Working"); for (int i = 1; i <= Int32.Parse(postNumber);) { // exit programm bool statusProgramm = programmStatus(); if (statusProgramm == true) break; if (currentIdNumberFollow == 11) { currentIdNumberFollow = 1; } if (currentIdNumberLike == 11) { currentIdNumberLike = 1; } if (currentIdNumberComm == 11) { currentIdNumberComm = 1; } string likePost = path["likePost"]; string loadPost = checkElementByXpath3(likePost); string downloadPostName = path["downloadPostName"]; string userName = getAttributeByXpath(downloadPostName, "innerHTML").Trim(); if (loadPost.Equals("false") && userName != userNick) { string checkLikeStatus = path["checkLikeStatus"]; string likeStatus = getAttributeByCssSelector(checkLikeStatus, "fill"); //like string likeFillWithoutLike = path["likeFillWithoutLike"]; if (likeStatus.Equals(likeFillWithoutLike)) { clickElementByXpath(likePost); string checkPostError = path["checkPostError"]; string errorCheck = checkElementByXpath2(checkPostError); saveLikeStats(currentIdNumberLike); currentIdNumberLike++; Thread.Sleep(600); useRandomTimeFast(); if (errorCheck.Equals("true")) { //follow string follow = data["follow"]; if (follow.Equals("yes")) { //co który post ma dac followa string postToFollow = data["postToFollow"]; if (i % Int32.Parse(postToFollow) == 0) { // follow limit if (currentFollow <= 60) { string checkFollowStatus = path["checkFollowStatus"]; string followStatus = getAttributeByXpath(checkFollowStatus, "class"); //follow status string followClassWithoutFollow = path["followClassWithoutFollow"]; if (followStatus.Equals(followClassWithoutFollow)) { string followAccount = path["followAccount"]; clickElementByXpath(followAccount); saveFollowStats(currentIdNumberFollow); currentFollow++; currentIdNumberFollow++; Thread.Sleep(500); useRandomTimeFast(); } } } } //comm string comment = data["comment"]; if (comment.Equals("yes")) { if (commError <= 5) { //limit komantarzy if (currentComment <= 50) { // co który post ma dostac komma string postToComment = data["postToComment"]; if (i % Int32.Parse(postToComment) == 0) { // czy nie ma blokady komm string checkCommentStatus = path["checkCommentStatus"]; string commentStatus = checkElementByXpath(checkCommentStatus); if (commentStatus.Equals("true")) { string textMessage = randomComm(); string writeComment = path["writeComment"]; clickElementByXpath(writeComment); Thread.Sleep(300); string writeCommentVisible = path["writeCommentVisible"]; sendKeysByXpath(writeCommentVisible, textMessage); Thread.Sleep(500); string sendComment = path["sendComment"]; clickElementByXpath(sendComment); Thread.Sleep(400); string commentAfterSendError = path["commentAfterSendError"]; string checkErrorComm = checkElementByXpath2(commentAfterSendError); // "spróbuj ponownie w komm" if (checkErrorComm.Equals("true")) { saveCommStats(currentIdNumberComm); currentIdNumberComm++; currentComment++; useRandomTimeFast(); } else { Console.WriteLine("Błąd w komantarzu"); commError++; } } } } } } i++; currentLike++; } else { Console.WriteLine("Napotkano ERROR, koniec programu"); string json4 = File.ReadAllText(@"config/data.json"); dynamic jsonObj4 = JsonConvert.DeserializeObject(json4); jsonObj4["igError"] = "True"; string output4 = JsonConvert.SerializeObject(jsonObj4, Formatting.Indented); File.WriteAllText(@"config/data.json", output4); Thread.Sleep(5000); driver.Close(); driver.Quit(); Environment.Exit(0); } //save stats to data.json string json = File.ReadAllText(@"config/data.json"); dynamic jsonObj = JsonConvert.DeserializeObject(json); jsonObj["currentLike"] = currentLike.ToString(); jsonObj["currentFollow"] = currentFollow.ToString(); jsonObj["currentComment"] = currentComment.ToString(); string totalLike = data["totalLike"]; jsonObj["totalLike"] = (currentLike + Int32.Parse(totalLike)).ToString(); string totalFollow = data["totalFollow"]; jsonObj["totalFollow"] = (currentFollow + Int32.Parse(totalFollow)).ToString(); string totalComment = data["totalComment"]; jsonObj["totalComment"] = (currentComment + Int32.Parse(totalComment)).ToString(); jsonObj["currentFollowId"] = currentIdNumberFollow.ToString(); jsonObj["currentLikeId"] = currentIdNumberLike.ToString(); jsonObj["currentCommId"] = currentIdNumberComm.ToString(); jsonObj["commError"] = commError.ToString(); string output = JsonConvert.SerializeObject(jsonObj, Formatting.Indented); File.WriteAllText(@"config/data.json", output); //save all likes in day (number) string json1 = File.ReadAllText(@"config/likeDay.json"); dynamic jsonObj1 = JsonConvert.DeserializeObject(json1); string date = DateTime.Now.ToString("dd.MM.yyy"); jsonObj1[date] = (currentLike + likeBefore).ToString(); string output1 = JsonConvert.SerializeObject(jsonObj1, Formatting.Indented); File.WriteAllText(@"config/likeDay.json", output1); //save all comm in day (number) string json5 = File.ReadAllText(@"co nfig/commDay.json"); dynamic jsonObj5 = JsonConvert.DeserializeObject(json5); jsonObj5[date] = (currentComment + commBefore).ToString(); string output5 = JsonConvert.SerializeObject(jsonObj5, Formatting.Indented); File.WriteAllText(@"config/commDay.json", output5); //save profile link string downloadPostLink = path["downloadPostLink"]; string profileLink = getAttributeByCssSelector(downloadPostLink, "href"); bool linkBefore = checkLink(profileLink); if (linkBefore == false) { string json3 = File.ReadAllText(@"config/linkToLike.json"); dynamic jsonObj3 = JsonConvert.DeserializeObject(json3); jsonObj3["Link_id" + linkNumber] = profileLink; string output3 = JsonConvert.SerializeObject(jsonObj3, Formatting.Indented); File.WriteAllText(@"config/linkToLike.json", output3); linkNumber++; } //next post string nextPost = path["nextPost"]; clickElementByXpath(nextPost); Thread.Sleep(500); } else { //next post string nextPost = path["nextPost"]; clickElementByXpath(nextPost); Thread.Sleep(600); } } else { //next post string nextPost = path["nextPost"]; clickElementByXpath(nextPost); Thread.Sleep(600); } } } static bool checkLink(string link) { string strResult = File.ReadAllText(@"config/linkTolike.json"); var dictionary = JsonConvert.DeserializeObject(strResult); foreach (DictionaryEntry elem in dictionary) { if (elem.Value.ToString().Equals(link)) { return true; } } return false; } static void startSafeProgramm() { string json20 = File.ReadAllText(@"config/data.json"); dynamic data = JsonConvert.DeserializeObject(json20); IJavaScriptExecutor js = (IJavaScriptExecutor)driver; int linkNumber = 1; int currentLike = 0; int currentFollow = 0; int currentComment = 0; string currentFollowId = data["currentFollowId"]; int currentIdNumberFollow = Int32.Parse(currentFollowId); string currentLikeId = data["currentLikeId"]; int currentIdNumberLike = Int32.Parse(currentLikeId); string currentCommId = data["currentCommId"]; int currentIdNumberComm = Int32.Parse(currentCommId); int commError = 0; string json2 = File.ReadAllText(@"config/data.json"); dynamic jsonObj2 = JsonConvert.DeserializeObject(json2); jsonObj2["commError"] = commError.ToString(); string output2 = JsonConvert.SerializeObject(jsonObj2, Formatting.Indented); File.WriteAllText(@"config/data.json", output2); string tag = data["tag"]; if (tag.Length > 20) { driver.Navigate().GoToUrl(tag); } else { driver.Navigate().GoToUrl("https://www.instagram.com/explore/tags/" + tag); } Thread.Sleep(2000); js.ExecuteScript("window.scrollTo(0, 500)"); Thread.Sleep(1000); int likeBefore = dayLike(); int commBefore = dayComm(); hashatagError(); string clickFirstPost = path["clickFirstPost"]; clickElementByXpath(clickFirstPost); string postNumber = data["postNumber"]; currentAction("Working - Safe Mode"); for (int i = 1; i <= Int32.Parse(postNumber);) { // exit programm bool statusProgramm = programmStatus(); if (statusProgramm == true) break; if (currentIdNumberFollow == 11) { currentIdNumberFollow = 1; } if (currentIdNumberLike == 11) { currentIdNumberLike = 1; } if (currentIdNumberComm == 11) { currentIdNumberComm = 1; } if (currentLike + likeBefore >= 1500) { string json4 = File.ReadAllText(@"config/data.json"); dynamic jsonObj4 = JsonConvert.DeserializeObject(json4); jsonObj4["igError"] = "True"; string output4 = JsonConvert.SerializeObject(jsonObj4, Formatting.Indented); File.WriteAllText(@"config/data.json", output4); Thread.Sleep(5000); driver.Close(); driver.Quit(); Environment.Exit(0); } string likePost = path["likePost"]; string loadPost = checkElementByXpath3(likePost); if (loadPost.Equals("false")) { string checkLikeStatus = path["checkLikeStatus"]; string likeStatus = getAttributeByCssSelector(checkLikeStatus, "fill"); //like string likeFillWithoutLike = path["likeFillWithoutLike"]; if (likeStatus.Equals(likeFillWithoutLike)) { clickElementByXpath(likePost); string checkPostError = path["checkPostError"]; string errorCheck = checkElementByXpath2(checkPostError); saveLikeStats(currentIdNumberLike); currentIdNumberLike++; Thread.Sleep(600); useRandomTimeSafe(); if (errorCheck.Equals("true")) { //follow string follow = data["follow"]; if (follow.Equals("yes")) { //co który post ma dac followa string postToFollow = data["postToFollow"]; if (i % Int32.Parse(postToFollow) == 0) { // follow limit if (currentFollow <= 60) { string checkFollowStatus = path["checkFollowStatus"]; string followStatus = getAttributeByXpath(checkFollowStatus, "class"); //follow status string followClassWithoutFollow = path["followClassWithoutFollow"]; if (followStatus.Equals(followClassWithoutFollow)) { string followAccount = path["followAccount"]; clickElementByXpath(followAccount); saveFollowStats(currentIdNumberFollow); currentFollow++; currentIdNumberFollow++; Thread.Sleep(500); useRandomTimeSafe(); } } } } //comm string comment = data["comment"]; if (comment.Equals("yes")) { if (commError <= 5) { //limit komantarzy if (currentComment <= 50) { // co który post ma dostac komma string postToComment = data["postToComment"]; if (i % Int32.Parse(postToComment) == 0) { // czy nie ma blokady komm string checkCommentStatus = path["checkCommentStatus"]; string commentStatus = checkElementByXpath(checkCommentStatus); if (commentStatus.Equals("true")) { string textMessage = randomComm(); string writeComment = path["writeComment"]; clickElementByXpath(writeComment); Thread.Sleep(300); string writeCommentVisible = path["writeCommentVisible"]; sendKeysByXpath(writeCommentVisible, textMessage); Thread.Sleep(500); string sendComment = path["sendComment"]; clickElementByXpath(sendComment); Thread.Sleep(400); string commentAfterSendError = path["commentAfterSendError"]; string checkErrorComm = checkElementByXpath2(commentAfterSendError); // "spróbuj ponownie w komm" if (checkErrorComm.Equals("true")) { saveCommStats(currentIdNumberComm); currentIdNumberComm++; currentComment++; useRandomTimeSafe(); } else { Console.WriteLine("Błąd w komantarzu"); commError++; } } } } } } i++; currentLike++; } else { Console.WriteLine("Napotkano ERROR, koniec programu"); string json4 = File.ReadAllText(@"config/data.json"); dynamic jsonObj4 = JsonConvert.DeserializeObject(json4); jsonObj4["igError"] = "True"; string output4 = JsonConvert.SerializeObject(jsonObj4, Formatting.Indented); File.WriteAllText(@"config/data.json", output4); Thread.Sleep(5000); driver.Close(); driver.Quit(); Environment.Exit(0); } //save stats to data.json string json = File.ReadAllText(@"config/data.json"); dynamic jsonObj = JsonConvert.DeserializeObject(json); jsonObj["currentLike"] = currentLike.ToString(); jsonObj["currentFollow"] = currentFollow.ToString(); jsonObj["currentComment"] = currentComment.ToString(); string totalLike = data["totalLike"]; jsonObj["totalLike"] = (currentLike + Int32.Parse(totalLike)).ToString(); string totalFollow = data["totalFollow"]; jsonObj["totalFollow"] = (currentFollow + Int32.Parse(totalFollow)).ToString(); string totalComment = data["totalComment"]; jsonObj["totalComment"] = (currentComment + Int32.Parse(totalComment)).ToString(); jsonObj["currentFollowId"] = currentIdNumberFollow.ToString(); jsonObj["currentLikeId"] = currentIdNumberLike.ToString(); jsonObj["currentCommId"] = currentIdNumberComm.ToString(); jsonObj["commError"] = commError.ToString(); string output = JsonConvert.SerializeObject(jsonObj, Formatting.Indented); File.WriteAllText(@"config/data.json", output); //save all likes in day (number) string json1 = File.ReadAllText(@"config/likeDay.json"); dynamic jsonObj1 = JsonConvert.DeserializeObject(json1); string date = DateTime.Now.ToString("dd.MM.yyy"); jsonObj1[date] = (currentLike + likeBefore).ToString(); string output1 = JsonConvert.SerializeObject(jsonObj1, Formatting.Indented); File.WriteAllText(@"config/likeDay.json", output1); //save all comm in day (number) string json5 = File.ReadAllText(@"config/commDay.json"); dynamic jsonObj5 = JsonConvert.DeserializeObject(json5); jsonObj5[date] = (currentComment + commBefore).ToString(); string output5 = JsonConvert.SerializeObject(jsonObj5, Formatting.Indented); File.WriteAllText(@"config/commDay.json", output5); //save profile link string downloadPostLink = path["downloadPostLink"]; string profileLink = getAttributeByCssSelector(downloadPostLink, "href"); bool linkBefore = checkLink(profileLink); if (linkBefore == false) { string json3 = File.ReadAllText(@"config/linkToLike.json"); dynamic jsonObj3 = JsonConvert.DeserializeObject(json3); jsonObj3["Link_id" + linkNumber] = profileLink; string output3 = JsonConvert.SerializeObject(jsonObj3, Formatting.Indented); File.WriteAllText(@"config/linkToLike.json", output3); linkNumber++; } if (i % 20 == 0) { Thread.Sleep(rnd.Next(300000, 350000)); } //next post string nextPost = path["nextPost"]; clickElementByXpath(nextPost); Thread.Sleep(500); } else { //next post string nextPost = path["nextPost"]; clickElementByXpath(nextPost); Thread.Sleep(600); } } else { //next post string nextPost = path["nextPost"]; clickElementByXpath(nextPost); Thread.Sleep(600); } } } static bool programmStatus() { string json100 = File.ReadAllText(@"neutralData.json"); dynamic neutral = JsonConvert.DeserializeObject(json100); bool x = neutral["exitTheProgram"]; return x; } static void numberOfAllFollowesInAccount() { string json2 = File.ReadAllText(@"config/data.json"); dynamic data = JsonConvert.DeserializeObject(json2); string checkFollowStatus = data["firstFollowCheck"]; string json3 = File.ReadAllText(@"neutralData.json"); dynamic neutral = JsonConvert.DeserializeObject(json3); string url = neutral["instagramUserName"]; driver.Navigate().GoToUrl("https://www.instagram.com/" + url); if (checkFollowStatus.Equals("false")) { Thread.Sleep(1000); string getNumberOfFollowesInAccount = path["getNumberOfFollowesInAccount"]; string numberOfAllFollows = getAttributeByCssSelector(getNumberOfFollowesInAccount, "title"); string json = File.ReadAllText(@"config/data.json"); dynamic jsonObj = JsonConvert.DeserializeObject(json); jsonObj["allFollowesBefore"] = numberOfAllFollows.ToString(); jsonObj["firstFollowCheck"] = "true"; string output = JsonConvert.SerializeObject(jsonObj, Formatting.Indented); File.WriteAllText(@"config/data.json", output); } } static void numberOfAllNewFollowesInAccount() { string json4 = File.ReadAllText(@"neutralData.json"); dynamic neutral = JsonConvert.DeserializeObject(json4); string url = neutral["instagramUserName"]; driver.Navigate().GoToUrl("https://www.instagram.com/" + url); Thread.Sleep(3000); string getNumberOfFollowesInAccount = path["getNumberOfFollowesInAccount"]; string numberOfAllFollows = getAttributeByCssSelector(getNumberOfFollowesInAccount, "title"); Thread.Sleep(1000); string json = File.ReadAllText(@"config/data.json"); dynamic jsonObj = JsonConvert.DeserializeObject(json); jsonObj["allFollowesAfter"] = numberOfAllFollows.ToString(); string output = JsonConvert.SerializeObject(jsonObj, Formatting.Indented); File.WriteAllText(@"config/data.json", output); Thread.Sleep(300); string date = DateTime.Now.ToString("dd.MM.yyy"); string json3 = File.ReadAllText(@"config/followDay.json"); dynamic jsonObj3 = JsonConvert.DeserializeObject(json3); string currentSaveDate = jsonObj3[date]; Console.WriteLine(currentSaveDate + "to"); if (currentSaveDate == null) { jsonObj3[date] = numberOfAllFollows.ToString(); string output3 = JsonConvert.SerializeObject(jsonObj3, Formatting.Indented); File.WriteAllText(@"config/followDay.json", output3); } string json2 = File.ReadAllText(@"config/data.json"); dynamic jsonObj2 = JsonConvert.DeserializeObject(json2); string followersToday = jsonObj3[date]; int moreFollowes = Int32.Parse(numberOfAllFollows) - Int32.Parse(followersToday); jsonObj2["newFollowersNumber"] = moreFollowes.ToString(); string output2 = JsonConvert.SerializeObject(jsonObj2, Formatting.Indented); File.WriteAllText(@"config/data.json", output2); } static bool codeCheck() { string json = File.ReadAllText(@"neutralData.json"); dynamic data = JsonConvert.DeserializeObject(json); int correctCode = (DateTime.Now.DayOfYear * 2137 * DateTime.DaysInMonth(2001, 2)); string code = data["code"]; int jsonCode = Int32.Parse(code); Console.WriteLine(correctCode); if (jsonCode == correctCode) { return true; } else { return false; } } public static string Decrypt(string cipherText) { string EncryptionKey = "Ex*igdqx49fX7ilPqIdYF!gZ"; cipherText = cipherText.Replace(" ", "+"); byte[] cipherBytes = Convert.FromBase64String(cipherText); using (Aes encryptor = Aes.Create()) { Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 }); encryptor.Key = pdb.GetBytes(32); encryptor.IV = pdb.GetBytes(16); using (MemoryStream ms = new MemoryStream()) { using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateDecryptor(), CryptoStreamMode.Write)) { cs.Write(cipherBytes, 0, cipherBytes.Length); cs.Close(); } cipherText = Encoding.Unicode.GetString(ms.ToArray()); } } return cipherText; } static void numberOfAllPostInAccount() { string getNumberOfPostInAccount = path["getNumberOfPostInAccount"]; string postNumber = getAttributeByXpath(getNumberOfPostInAccount, "innerHTML"); string json = File.ReadAllText(@"config/data.json"); dynamic jsonObj = JsonConvert.DeserializeObject(json); jsonObj["totalPostInAccount"] = postNumber.ToString(); string output = JsonConvert.SerializeObject(jsonObj, Formatting.Indented); File.WriteAllText(@"config/data.json", output); } static void getPostAndFollowesNumber() { currentAction("Working - Get Stats"); numberOfAllFollowesInAccount(); numberOfAllNewFollowesInAccount(); //numberOfAllPostInAccount(); downloadUserPhoto(); } static void getUserName() { currentLoginStatus(3); string quitInstagramNotifi = path["quitInstagramNotifi"]; string notifyStatus = checkElementByXpath2(quitInstagramNotifi); if (notifyStatus.Equals("false")) { clickElementByXpath(quitInstagramNotifi); } string profileMenuBar = path["profileMenuBar"]; clickElementByXpath(profileMenuBar); Thread.Sleep(1000); string goToProfile = path["goToProfile"]; clickElementByXpath(goToProfile); //save user name string getUserName = path["getUserName"]; string accountName = getAttributeByXpath(getUserName, "innerHTML"); string json20 = File.ReadAllText(@"neutralData.json"); dynamic jsonObj20 = JsonConvert.DeserializeObject(json20); jsonObj20["instagramUserName"] = accountName; string output20 = JsonConvert.SerializeObject(jsonObj20, Formatting.Indented); File.WriteAllText(@"neutralData.json", output20); Thread.Sleep(100); currentLoginStatus(4); } static void downloadUserPhoto() { WebClient client = new WebClient(); try { Thread.Sleep(1000); string downloadUserPhotoInAccount = path["downloadUserPhotoInAccount"]; string url = driver.FindElement(By.XPath(downloadUserPhotoInAccount)).GetAttribute("src"); client.DownloadFile(new Uri(url), @"config/userPhoto.jpeg"); } catch { Thread.Sleep(100); } try { Thread.Sleep(1000); string secondDownloadUserPhoto = path["secondDownloadUserPhoto"]; string url = driver.FindElement(By.XPath(secondDownloadUserPhoto)).GetAttribute("src"); client.DownloadFile(new Uri(url), @"config/userPhoto.jpeg"); } catch { Thread.Sleep(100); } } static void saveFollowStats(int followIdNumber) { string json2 = File.ReadAllText(@"config/data.json"); dynamic data = JsonConvert.DeserializeObject(json2); WebClient client = new WebClient(); string downloadPostPhoto = path["downloadPostPhoto"]; string photoUrl = getAttributeByCssSelector2(downloadPostPhoto, "src"); string downloadPostName = path["downloadPostName"]; string userName = getAttributeByXpath(downloadPostName, "innerHTML"); if (photoUrl.Equals("false") || data["savePhoto"].Equals("false")) { System.IO.File.Copy("none.jpg", @"photoFollow/name_id" + followIdNumber + ".jpeg", true); } else { client.DownloadFile(new Uri(photoUrl), @"photoFollow/name_id" + followIdNumber + ".jpeg"); } string json = File.ReadAllText(@"config/followNames.json"); dynamic jsonObj = JsonConvert.DeserializeObject(json); jsonObj["name_Id" + followIdNumber] = userName; string output = JsonConvert.SerializeObject(jsonObj, Formatting.Indented); File.WriteAllText(@"config/followNames.json", output); } static void saveLikeStats(int likeIdNumber) { string json2 = File.ReadAllText(@"config/data.json"); dynamic data = JsonConvert.DeserializeObject(json2); WebClient client = new WebClient(); string downloadPostPhoto = path["downloadPostPhoto"]; string photoUrl = getAttributeByCssSelector2(downloadPostPhoto, "src"); string downloadPostName = path["downloadPostName"]; string userName = getAttributeByXpath(downloadPostName, "innerHTML"); if (photoUrl.Equals("false") || data["savePhoto"].Equals("false")) { System.IO.File.Copy("none.jpg", @"photoLike/name_id" + likeIdNumber + ".jpeg", true); } else { client.DownloadFile(new Uri(photoUrl), @"photoLike/name_id" + likeIdNumber + ".jpeg"); } string json = File.ReadAllText(@"config/likeNames.json"); dynamic jsonObj = JsonConvert.DeserializeObject(json); jsonObj["name_Id" + likeIdNumber] = userName; string output = JsonConvert.SerializeObject(jsonObj, Formatting.Indented); File.WriteAllText(@"config/likeNames.json", output); } static void saveCommStats(int likeIdNumber) { string json2 = File.ReadAllText(@"config/data.json"); dynamic data = JsonConvert.DeserializeObject(json2); WebClient client = new WebClient(); string downloadPostPhoto = path["downloadPostPhoto"]; string photoUrl = getAttributeByCssSelector2(downloadPostPhoto, "src"); string downloadPostName = path["downloadPostName"]; string userName = getAttributeByXpath(downloadPostName, "innerHTML"); if (photoUrl.Equals("false") || data["savePhoto"].Equals("false")) { System.IO.File.Copy("none.jpg", @"photoComm/name_id" + likeIdNumber + ".jpeg", true); } else { client.DownloadFile(new Uri(photoUrl), @"photoComm/name_id" + likeIdNumber + ".jpeg"); } string json = File.ReadAllText(@"config/commNames.json"); dynamic jsonObj = JsonConvert.DeserializeObject(json); jsonObj["name_Id" + likeIdNumber] = userName; string output = JsonConvert.SerializeObject(jsonObj, Formatting.Indented); File.WriteAllText(@"config/commNames.json", output); } static void kindOfProgramm() { string json = File.ReadAllText(@"config/data.json"); dynamic data = JsonConvert.DeserializeObject(json); string programType = data["kindOfProgramm"]; if (programType.Equals("safe")) { startSafeProgramm(); } else if (programType.Equals("fast")) { startFastProgramm(); } else { Console.WriteLine("Error Programm type"); } } static void likePostFromLink() { string json2 = File.ReadAllText(@"config/data.json"); dynamic data = JsonConvert.DeserializeObject(json2); int likeBefore = dayProfileLike(); currentAction("Working - Like Posts In Accounts"); string likePostFromLink = data["likePostFromLink"]; if (likePostFromLink.Equals("true")) { int currentLike = 0; IJavaScriptExecutor js = (IJavaScriptExecutor)driver; string strResult = File.ReadAllText(@"config/linkTolike.json"); var dictionary = JsonConvert.DeserializeObject(strResult); foreach (DictionaryEntry elem in dictionary) { // exit programm bool statusProgramm = programmStatus(); if (statusProgramm == true) break; string like = data["likeFromLinksNumber"]; if (currentLike <= Int32.Parse(like)) { Thread.Sleep(1000); Console.WriteLine(elem.Value); driver.Navigate().GoToUrl(elem.Value.ToString()); Thread.Sleep(1000); string noAccount = path["noAccount"]; int noAccount1 = driver.FindElements(By.ClassName(noAccount)).Count; string clickFirstPostInAccount = path["clickFirstPostInAccount"]; int availabePost = driver.FindElements(By.ClassName(clickFirstPostInAccount)).Count; if (noAccount1 == 0 && availabePost != 0) { Thread.Sleep(2000); js.ExecuteScript("window.scrollTo(0, 400)"); Thread.Sleep(400); clickElementByClassName(clickFirstPostInAccount); int likeRandom = rnd.Next(3, 5); for (int i = 1; i <= likeRandom;) { string checkPostError = path["checkPostError"]; string errorCheck = checkElementByXpath2(checkPostError); string likePost = path["likePost"]; string loadPost = checkElementByXpath3(likePost); if (errorCheck.Equals("true")) { if (loadPost.Equals("false")) { string nextPostInAccount = path["nextPostInAccount"]; string nextPostStatus = checkElementByXpath2(nextPostInAccount); Console.WriteLine(nextPostStatus); if (nextPostStatus.Equals("false")) { string checkLikeStatus1 = path["checkLikeStatus"]; string checkLikeStatus = getAttributeByCssSelector(checkLikeStatus1, "fill"); string likeFillWithoutLike = path["likeFillWithoutLike"]; if (checkLikeStatus.Equals(likeFillWithoutLike)) { i++; currentLike++; //like post useRandomTimeFast(); clickElementByXpath(likePost); //save like in day string json5 = File.ReadAllText(@"config/profileLikeDay.json"); dynamic jsonObj5 = JsonConvert.DeserializeObject(json5); string date = DateTime.Now.ToString("dd.MM.yyy"); jsonObj5[date] = (currentLike + likeBefore).ToString(); string output5 = JsonConvert.SerializeObject(jsonObj5, Formatting.Indented); File.WriteAllText(@"config/profileLikeDay.json", output5); //check error string errorCheck1 = checkElementByXpath2(checkPostError); if (errorCheck1.Equals("true")) { useRandomTimeFast(); //next post clickElementByXpath(nextPostInAccount); string json = File.ReadAllText(@"config/data.json"); dynamic jsonObj = JsonConvert.DeserializeObject(json); jsonObj["likesInAccountFromLinks"] = currentLike.ToString(); string likes = data["totalLikeFromLinksNumber"]; jsonObj["totalLikeFromLinksNumber"] = (Int32.Parse(likes) + currentLike).ToString(); string output = JsonConvert.SerializeObject(jsonObj, Formatting.Indented); File.WriteAllText(@"config/data.json", output); Thread.Sleep(rnd.Next(400, 700)); } else { Console.WriteLine("Napotkano ERROR, koniec programu"); string json4 = File.ReadAllText(@"config/data.json"); dynamic jsonObj4 = JsonConvert.DeserializeObject(json4); jsonObj4["igError"] = "True"; string output4 = JsonConvert.SerializeObject(jsonObj4, Formatting.Indented); File.WriteAllText(@"config/data.json", output4); Thread.Sleep(5000); Environment.Exit(0); } } else { // next post clickElementByXpath(nextPostInAccount); useRandomTimeFast(); } } else { i = 7; Thread.Sleep(rnd.Next(250, 350)); } ///html/body/div[4]/div[1]/div/div/a ///html/body/div[4]/div[1]/div/div/a[2] } else { string nextPostInAccount = path["nextPostInAccount"]; string nextPostStatus = checkElementByXpath2(nextPostInAccount); Console.WriteLine(nextPostStatus); if (nextPostStatus.Equals("false")) { clickElementByXpath(nextPostInAccount); useRandomTimeFast(); } else { i = 4; useRandomTimeFast(); } } } else { Console.WriteLine("Napotkano ERROR, koniec programu"); string json4 = File.ReadAllText(@"config/data.json"); dynamic jsonObj4 = JsonConvert.DeserializeObject(json4); jsonObj4["igError"] = "True"; string output4 = JsonConvert.SerializeObject(jsonObj4, Formatting.Indented); File.WriteAllText(@"config/data.json", output4); Thread.Sleep(5000); Environment.Exit(0); } } } } } } } static void accountAge() { Thread.Sleep(1000); driver.Navigate().GoToUrl("https://www.instagram.com/accounts/access_tool/?hl=pl"); Thread.Sleep(1000); string accountDate = path["accountDate"]; string dateWithHour = getAttributeByXpath(accountDate, "innerHTML").Trim(); string date = string.Concat(dateWithHour.Reverse().Skip(6).Reverse()); Console.WriteLine(date); DateTime time = DateTime.Parse(date); DateTime now = DateTime.Now; float day = (now - time).Days; Console.WriteLine(day); string json = File.ReadAllText(@"config/data.json"); dynamic data = JsonConvert.DeserializeObject(json); string followNumberS = data["allFollowesAfter"]; float followNumber = Convert.ToSingle(followNumberS); Console.WriteLine(followNumber); data["rate"] = followNumber / day; Console.WriteLine(followNumber / day); string output = JsonConvert.SerializeObject(data, Formatting.Indented); File.WriteAllText(@"config/data.json", output); } } }