private void Browser_JavascriptMessageReceived(object sender, JavascriptMessageReceivedEventArgs e) { var msg = (string)e.Message; Bot.Log(msg); }
private async void BootstrapClient() { string lines = ""; #if DEBUG // === Replacement for Logic.js === lines = File.ReadAllText(@"C:\Users\Abdullah\Desktop\ArColWeb\src\public\source\client_c.bin"); #else lines = Client.scriptCode; #endif var decText = StringCipher.Decrypt(lines, "enjoylowlife"); int quantity = 10000; string cannonBallType = "_id.cannonballDivisional"; string pirateType = "Juliette"; metroComboBoxQuantity.Invoke((MethodInvoker)(() => { quantity = Convert.ToInt32(metroComboBoxQuantity.Text); })); metroComboBoxCbType.Invoke((MethodInvoker)(() => { cannonBallType = metroComboBoxCbType.Text; switch (cannonBallType) { case "Divisional": cannonBallType = "_id.cannonballDivisional"; break; case "Hollow": cannonBallType = "_id.cannonballHollow"; break; case "Stone": cannonBallType = "_id.cannonballStone"; break; case "Slime": cannonBallType = "_id.cannonballSlime"; break; default: cannonBallType = "_id.cannonballHollow"; break; } })); metroComboBoxEquipPirates.Invoke((MethodInvoker)(() => { pirateType = metroComboBoxEquipPirates.Text; })); await browser.EvaluateScriptAsync("let shootObj=[];" + "bs = {" + " cb:false," + " sa:false," + " buyCannonball:{}," + " equipPirates:{}," + " sn:false," + " ai:false," + " onlyFullHp:" + " false," + " repLimit:50" + "}"); if (collectboxcheckbox.Checked) { await browser.EvaluateScriptAsync("bs.cb=true;"); } if (shootmonstercheckbox.Checked) { await browser.EvaluateScriptAsync("bs.sa=true;"); } if (shootnpccheckbox.Checked) { await browser.EvaluateScriptAsync("bs.sn=true;"); } if (avoidislandcheckbox.Checked) { await browser.EvaluateScriptAsync("bs.ai=true;"); } if (checkBoxShootBack.Checked) { await browser.EvaluateScriptAsync("bs.shootBack=true;"); } if (checkBoxEquipSails.Checked) { await browser.EvaluateScriptAsync("bs.equipSails=true;"); } if (checkboxShootOnlyFullHp.Checked) { await browser.EvaluateScriptAsync("bs.onlyFullHp=true;"); } if (checkBoxBuyCannonballs.Checked) { await browser.EvaluateScriptAsync("bs.buyCannonball.active=true;" + "bs.buyCannonball.type=" + cannonBallType + ";" + "bs.buyCannonball.quantity= " + quantity + ";" + "bs.buyCannonball.ifBelow= " + numericUpDownIfBelow.Value + ";"); } if (metroCheckBoxEquipPirates.Checked) { await browser.EvaluateScriptAsync("bs.equipPirates.active=true;" + "bs.equipPirates.type=" + pirateType + ";"); } await browser.EvaluateScriptAsync("bs.repLimit=" + numericUpDown1.Value + ";"); if (collectboxcheckbox.Checked || shootnpccheckbox.Checked || shootmonstercheckbox.Checked) { await browser.EvaluateScriptAsync(decText); // change this !!! if (listBox1.Items.Count > 0) { foreach (var item in listBox1.Items) { await browser.EvaluateScriptAsync("shootObj.push(\"" + item + "\");") .ContinueWith(t => { if (!t.IsFaulted) { var response = t.Result; Bot.Log(response.Message); } }); } } Client.sessionStartTime = DateTime.Now; Client.running = true; buttonStart.Text = "Stop"; Bot.Log("Bot started."); } else { Bot.Log("Check at least one checkbox to perform tasks!"); } if (fakeMove.Enabled != true) { fakeMove.Enabled = true; fakeMove.Elapsed += FakeMove_Elapsed; fakeMove.Start(); } }
private void saveSettingsButton_Click(object sender, EventArgs e) { Bot.Log("Saved settings."); SaveUserSettings(); }
private void Browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e) { if (e.Frame.IsMain) { loginButton.Invoke((MethodInvoker)(() => { loginButton.Enabled = true; })); if (browser.Address.Contains("homepage")) { browser.ExecuteScriptAsync("document.getElementsByClassName('col-md-offset-4 playbutton fs-30 hvr-wobble-to-bottom-right')[0].click();"); browser.GetSourceAsync().ContinueWith(taskHtml => { var html = taskHtml.Result; string pattern = @"([A-Za-z0-9]+)<\/b>"; var m = Regex.Matches(html, pattern); Account.ID = m[0].Groups[1].Value; Account.UserName = m[1].Groups[1].Value; Account.Level = m[2].Groups[1].Value; Account.Rank = m[3].Groups[1].Value; }); } else if (browser.Address.Contains("play")) { Bot.Log("Loading game..."); browser.ExecuteScriptAsync("document.getElementsByClassName('btn btn-sm btn-default')[2].click();"); browser.GetSourceAsync().ContinueWith(taskHtml => { var html = taskHtml.Result; if (html.Contains("Multiple entries!") || html.Contains("Birden fazla giriş!")) { Thread.Sleep(3000); BotClick(450, 340); } if (Client.manuelStart) { Task.Delay(5000).ContinueWith(action => { var script = @"(function () { if (ArmadaBattle && ArmadaBattle.Game && ArmadaBattle.Game.myPlayer) return true; })();"; var result = browser.EvaluateScriptAsync(script).ContinueWith(x => { var response = x.Result; if (response.Success && response.Result != null) { if ((dynamic)response.Result == true) { Task.Delay(2000).ContinueWith(a => { Bot.Log("Restarting..."); BootstrapClient(); }); } } }); }); } }); Client.ready = true; } } }