Skip to content

Commit 09abe98

Browse files
committed
fix watch ads but ads is autoplay (The f is that ? why on earth they add this)
1 parent 149e600 commit 09abe98

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

TbsCore/Tasks/LowLevel/UpgradeBuilding.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,22 @@ private async Task<bool> TryFastUpgrade(Account acc)
358358

359359
var elementIframe = acc.Wb.Driver.FindElement(By.XPath(nodeIframe.XPath));
360360
Actions act = new Actions(acc.Wb.Driver);
361-
act.MoveToElement(elementIframe).Click().Build().Perform();
361+
var action = act.MoveToElement(elementIframe).Click().Build();
362+
action.Perform();
363+
364+
await Task.Delay(rand.Next(10000, 15000));
365+
var handles = acc.Wb.Driver.WindowHandles;
366+
367+
while (handles.Count > 1)
368+
{
369+
acc.Logger.Information("Detect auto play ads, bot maybe pause ads. Great work Travian Devs");
370+
var current = acc.Wb.Driver.CurrentWindowHandle;
371+
var other = acc.Wb.Driver.WindowHandles.FirstOrDefault(x => !x.Equals(current));
372+
acc.Wb.Driver.SwitchTo().Window(other);
373+
acc.Wb.Driver.Close();
374+
acc.Wb.Driver.SwitchTo().Window(current);
375+
action.Perform();
376+
}
362377
}
363378

364379
acc.Logger.Information("Clicked play button, if ads doesn't play please click to help bot");

0 commit comments

Comments
 (0)