Skip to content

Commit dedf43e

Browse files
committed
trick to make bot click correct play button
1 parent 91d8407 commit dedf43e

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

TbsCore/Tasks/LowLevel/UpgradeBuilding.cs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,6 @@ private async Task<bool> TryFastUpgrade(Account acc)
343343
// click to play video
344344
acc.Logger.Information("Waiting ads video load before clicking play button");
345345
await Task.Delay(rand.Next(5000, 9000));
346-
acc.Logger.Information("Clicked play button, if ads doesn't play please click to help bot");
347-
acc.Logger.Information("Cooldown 3 mins. If building cannot upgrade will use normal button");
348346

349347
{
350348
var result = await Update(acc);
@@ -353,21 +351,18 @@ private async Task<bool> TryFastUpgrade(Account acc)
353351
var nodeIframe = acc.Wb.Html.GetElementbyId("videoFeature");
354352
if (nodeIframe == null)
355353
{
356-
await acc.Wb.Refresh();
357354
return false;
358355
}
359-
var elementIframe = acc.Wb.Driver.FindElementById("videoFeature");
360-
elementIframe.Click();
361-
362-
// if bot click failed and open new tab ( well done Travian devs, well done)
363-
await Task.Delay(rand.Next(5000, 9000));
364356

365-
while (!acc.Wb.Driver.Url.Contains(acc.AccInfo.ServerUrl))
366357
{
367-
acc.Wb.Driver.Close();
368-
await Task.Delay(rand.Next(1000, 2000));
358+
var elementIframe = acc.Wb.Driver.FindElement(By.XPath(nodeIframe.XPath));
359+
Actions act = new Actions(acc.Wb.Driver);
360+
act.MoveToElement(elementIframe).Click().Build().Perform();
369361
}
370362

363+
acc.Logger.Information("Clicked play button, if ads doesn't play please click to help bot");
364+
acc.Logger.Information("Cooldown 3 mins. If building cannot upgrade will use normal button");
365+
371366
try
372367
{
373368
await DriverHelper.WaitPageChange(acc, "dorf", 3);

0 commit comments

Comments
 (0)