Esempio n. 1
0
        public override async Task <TaskRes> Execute(Account acc)
        {
            if (!TaskExecutor.IsLoginScreen(acc))
            {
                await Task.Delay(AccountHelper.Delay() * 2);

                return(TaskRes.Executed);
            }

            var access = acc.Access.GetCurrentAccess();

            if (acc.AccInfo.ServerUrl.Contains("ttwars"))
            {
                await DriverHelper.WriteByName(acc, "user", acc.AccInfo.Nickname);

                await DriverHelper.WriteByName(acc, "pw", access.Password);
            }
            else
            {
                await DriverHelper.WriteByName(acc, "name", acc.AccInfo.Nickname);

                await DriverHelper.WriteByName(acc, "password", access.Password);
            }

            await DriverHelper.ClickByName(acc, "s1");

            if (TaskExecutor.IsLoginScreen(acc))
            {
                // Wrong password/nickname
                acc.Wb.Log("Password is incorrect!");
                acc.TaskTimer.Stop();
            }
            else
            {
                await TaskExecutor.PageLoaded(acc);

                // check sitter account
                var auction = acc.Wb.Html.DocumentNode.SelectSingleNode("//a[contains(@class,'auction')]");

                acc.Access.GetCurrentAccess().IsSittering = (auction != null && auction.HasClass("disable"));
            }

            return(TaskRes.Executed);
        }
Esempio n. 2
0
        public override async Task <TaskRes> Execute(Account acc)
        {
            if (!TaskExecutor.IsLoginScreen(acc))
            {
                await Task.Delay(AccountHelper.Delay() * 2);

                return(TaskRes.Executed);
            }

            var access = acc.Access.GetCurrentAccess();

            if (acc.AccInfo.ServerUrl.Contains("ttwars"))
            {
                await DriverHelper.WriteByName(acc, "user", acc.AccInfo.Nickname);

                await DriverHelper.WriteByName(acc, "pw", access.Password);
            }
            else
            {
                await DriverHelper.WriteByName(acc, "name", acc.AccInfo.Nickname);

                await DriverHelper.WriteByName(acc, "password", access.Password);
            }

            await DriverHelper.ClickByName(acc, "s1");

            if (TaskExecutor.IsLoginScreen(acc))
            {
                // Wrong password/nickname
                acc.Wb.Log("Password is incorrect!");
                acc.TaskTimer.Stop();
            }
            else
            {
                await TaskExecutor.PageLoaded(acc);
            }

            return(TaskRes.Executed);
        }
Esempio n. 3
0
        /// <summary>
        /// Tries to watch an Ad for +25% faster upgrade
        /// </summary>
        /// <param name="acc">Account</param>
        /// <returns>Whether bot watched the ad</returns>
        private async Task <bool> TryFastUpgrade(Account acc)
        {
            if (!await DriverHelper.ClickByClassName(acc, "videoFeatureButton green", false))
            {
                return(false);
            }

            // Accept ads
            if (await DriverHelper.ClickByName(acc, "adSalesVideoInfoScreen", false))
            {
                await DriverHelper.ExecuteScript(acc, "jQuery(window).trigger('showVideoWindowAfterInfoScreen')");
            }

            // Has to be a legit "click"
            acc.Wb.Driver.FindElementById("videoFeature").Click();

            var timeout = DateTime.Now.AddSeconds(100);

            do
            {
                await System.Threading.Tasks.Task.Delay(1000);

                if (timeout < DateTime.Now)
                {
                    return(false);
                }
            }while (acc.Wb.Driver.Url.Contains("build.php"));

            // Don't show again
            acc.Wb.UpdateHtml();
            if (acc.Wb.Html.GetElementbyId("dontShowThisAgain") != null)
            {
                await DriverHelper.ClickById(acc, "dontShowThisAgain");

                await DriverHelper.ClickByClassName(acc, "dialogButtonOk ok");
            }
            return(true);
        }
Esempio n. 4
0
        /// <summary>
        /// Tries to watch an Ad for +25% faster upgrade
        /// </summary>
        /// <param name="acc">Account</param>
        /// <returns>Whether bot watched the ad</returns>
        private async Task <bool> TryFastUpgrade(Account acc)
        {
            if (!await DriverHelper.ClickByClassName(acc, "videoFeatureButton green", false))
            {
                return(false);
            }
            await System.Threading.Tasks.Task.Delay(AccountHelper.Delay());

            // Confirm
            acc.Wb.UpdateHtml();
            if (acc.Wb.Html.DocumentNode.SelectSingleNode("//input[@name='adSalesVideoInfoScreen']") != null)
            {
                await DriverHelper.ClickByName(acc, "adSalesVideoInfoScreen");

                await System.Threading.Tasks.Task.Delay(AccountHelper.Delay());

                await DriverHelper.ExecuteScript(acc, "jQuery(window).trigger('showVideoWindowAfterInfoScreen')");

                await System.Threading.Tasks.Task.Delay(AccountHelper.Delay());
            }

            // Has to be a legit "click"
            acc.Wb.Driver.FindElementById("videoFeature").Click();

            // wait for finish watching ads
            var timeout = DateTime.Now.AddSeconds(100);

            do
            {
                await System.Threading.Tasks.Task.Delay(3000);

                //skip ads from Travian Games
                //they use ifarme to emebed ads video to their game
                acc.Wb.UpdateHtml();
                if (acc.Wb.Html.GetElementbyId("videoArea") != null)
                {
                    acc.Wb.Driver.SwitchTo().Frame(acc.Wb.Driver.FindElementById("videoArea"));
                    // trick to skip
                    await DriverHelper.ExecuteScript(acc, "var video = document.getElementsByTagName('video')[0];video.currentTime = video.duration - 1;", false, false);

                    //back to first page
                    acc.Wb.Driver.SwitchTo().DefaultContent();
                }
                if (timeout < DateTime.Now)
                {
                    return(false);
                }
            }while (acc.Wb.Driver.Url.Contains("build.php"));

            // Don't show again
            acc.Wb.UpdateHtml();
            if (acc.Wb.Html.GetElementbyId("dontShowThisAgain") != null)
            {
                await DriverHelper.ClickById(acc, "dontShowThisAgain");

                await System.Threading.Tasks.Task.Delay(AccountHelper.Delay());

                await DriverHelper.ClickByClassName(acc, "dialogButtonOk ok");
            }

            return(true);
        }