Пример #1
0
        static async Task <string[]> GrabCodesJoyReactor()
        {
            var profilePath = Paths.GetChromiumUserDataDir("*****@*****.**");

            PptrUtils.ProfilePath = profilePath;
            _page = PptrUtils.Page;

            string[] codes = Array.Empty <string>();

            string url = "http://gi.reactor.cc/tag/Genshin+Impact+Codes/new";
            await _page.GoToAsync(url, 555555, new[] { WaitUntilNavigation.Load });

            var posts = await _page.QuerySelectorAllAsync(".postContainer .post_content");

            foreach (var post in posts)
            {
                var postCodes = await post.EvaluateFunctionAsync <string[]>("post => post.innerText.match(/[A-Z0-9]+/g).filter(match => match.length>9)");

                codes = codes.Union(postCodes).ToArray();
            }

            await PptrUtils.CloseAsync();

            return(codes);
        }
Пример #2
0
        static async Task Main()
        {
            var credentialsCfgPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "accounts.json");
            var credentialsCfgText = await File.ReadAllTextAsync(credentialsCfgPath, Encoding.UTF8);

            var accounts = JsonValue.Parse(credentialsCfgText);

            foreach (JsonValue account in accounts)
            {
                try
                {
                    string login    = account["login"].ToString().Trim('\"');
                    string password = account["password"].ToString().Trim('\"');

                    Console.WriteLine("Profile: " + login);

                    var profilePath = Paths.GetChromiumUserDataDir(login);
                    PptrUtils.ProfilePath = profilePath;
                    _page = PptrUtils.Page;
                    await Auth(login, password);
                    await Bump();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
                finally
                {
                    await PptrUtils.CloseAsync();
                }
            }
        }
Пример #3
0
        static async Task <string[]> GrabCodesFandomWiki()
        {
            var profilePath = Paths.GetChromiumUserDataDir("*****@*****.**");

            PptrUtils.ProfilePath = profilePath;
            _page = PptrUtils.Page;

            var url = "https://genshin-impact.fandom.com/wiki/Promotional_Codes";
            await _page.GoToAsync(url, 153000, new[] { WaitUntilNavigation.Networkidle2 });

            string grabberScriptPath = Path.Combine(
                // System.Reflection.Assembly.GetEntryAssembly().Location,
                // Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase),
                AppDomain.CurrentDomain.BaseDirectory,
                "scripts",
                "promo_codes_grabber.js"
                );
            var grabberScript = await File.ReadAllTextAsync(grabberScriptPath);

            var activeCodes = await _page.EvaluateExpressionAsync <string[]>(grabberScript);

            await PptrUtils.CloseAsync();

            return(activeCodes);
        }
Пример #4
0
        static async Task Main()
        {
            Console.WriteLine("Hello!");

            var profilePath = Paths.GetChromiumUserDataDir("*****@*****.**");

            PptrUtils.ProfilePath = profilePath;
            _page = PptrUtils.Page;

            await Auth();

            var freeGamesLinks = await GetFreeGamesLinks();

            foreach (var url in freeGamesLinks)
            {
                Console.WriteLine(url);
                await _page.GoToAsync(url, WaitUntilNavigation.Load);

                try
                {
                    await AgreeAgeTakeover();

                    await _page.WaitForSelectorAsync("[data-component='BaseButton'][data-testid='purchase-cta-button']", PptrUtils.ShortSelectorAwaiter);

                    var purchaseButtons = await _page.QuerySelectorAllAsync("[data-component='BaseButton'][data-testid='purchase-cta-button']");

                    foreach (ElementHandle purchaseButton in purchaseButtons)
                    {
                        var purchaseButtonText = await _page.EvaluateFunctionAsync <string>("e => e.innerText.toLowerCase()", purchaseButton);

                        if (purchaseButtonText != "get")
                        {
                            continue;
                        }
                        await purchaseButton.ClickAsync();

                        Thread.Sleep(10000);

                        var purchaseFrame = await _page.QuerySelectorAsync("#webPurchaseContainer iframe");

                        var purchaseFrameContent = await purchaseFrame.ContentFrameAsync();

                        var submitButton = await purchaseFrameContent.QuerySelectorAsync("#purchaseAppContainer div.confirm-container button");

                        await submitButton.ClickAsync();

                        await _page.WaitForSelectorAsync("[data-component='PostPurchaseModal']", PptrUtils.ShortSelectorAwaiter);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }

            await PptrUtils.CloseAsync();

            Console.WriteLine("Bye!");
        }
        private static async Task GrabAnswers()
        {
            var profilePath = Paths.GetChromiumUserDataDir("*****@*****.**");

            PptrUtils.ProfilePath = profilePath;
            _page = PptrUtils.Page;

            try { await GrabGameWithAnswers(); } catch (Exception) { /* ignored */ }
            try { await GrabGameEightAnswers(); } catch (Exception) { /* ignored */ }
            try { await GrabGoogleDocsAnswers(); } catch (Exception) { /* ignored */ }
            try { await GrabDualShockersAnswers(); } catch (Exception) { /* ignored */ }

            await PptrUtils.CloseAsync();
        }
Пример #6
0
        public static async Task Run()
        {
            foreach (string profileName in GenshinSharedUtils.ProfileNames)
            {
                try
                {
                    Console.WriteLine("Profile: " + profileName);

                    var profilePath = Paths.GetChromiumUserDataDir(profileName);
                    PptrUtils.ProfilePath = profilePath;
                    _page = PptrUtils.Page;

                    const string url = "https://webstatic-sea.mihoyo.com/ys/event/e20210901people/index.html?auth_appid=e20210901invite";
                    await _page.GoToAsync(url, WaitUntilNavigation.Load);

                    System.Threading.Thread.Sleep(5310); //wait error message disappear

                    if (!await GenshinSharedUtils.CheckAuth(_page))
                    {
                        throw new Exception("Auth problem!");
                    }

                    /*
                     * await PptrUtils.ClickIfExists("p.top-btn-title");
                     *
                     * const string questionSelector = "p[class^='components-game-assets-qa-info___title--'] p[class^='components-game-assets-qa-info___text--']";
                     * const string variantsSelector = "div[class^='components-game-assets-qa-info___options-item--'][class^='components-game-assets-qa-info___options-']";
                     * var variantCleaner = new Regex(@"^[A-Z]+\.\s");
                     *
                     * for (int i = 0; i < 11; i++)
                     * {
                     *  System.Threading.Thread.Sleep(3555); //wait animation
                     *
                     *  var questionTag = await _page.QuerySelectorAsync(questionSelector);
                     *  if (questionTag == null) continue;
                     *  var questionText = await questionTag.EvaluateFunctionAsync<string>("e => e.innerText");
                     *  questionText = ProcessString(questionText);
                     *
                     *  var answers = QaDict.Where(qa => qa[0] == questionText).ToList();
                     *
                     *  if (answers.Count == 0) throw new Exception("Unknown question: " + questionText);
                     *
                     *  var variants = await _page.QuerySelectorAllAsync(variantsSelector);
                     *  bool answered = false;
                     *  foreach (var variant in variants)
                     *  {
                     *      var variantText = await variant.EvaluateFunctionAsync<string>("e => e.innerText");
                     *      variantText = variantCleaner.Replace(variantText, "");
                     *      variantText = ProcessString(variantText);
                     *      bool isRight = answers.Any(qa => qa[1] == variantText);
                     *      if (!isRight) continue;
                     *      answered = true;
                     *      await variant.ClickAsync();
                     *      break;
                     *  }
                     *  if (answered) continue;
                     *  foreach (var variant in variants)
                     *  {
                     *      var variantText = await variant.EvaluateFunctionAsync<string>("e => e.innerText");
                     *      variantText = variantCleaner.Replace(variantText, "");
                     *      variantText = ProcessString(variantText);
                     *      bool isSimilar = answers.Any(qa => CalculateSimilarity(variantText, qa[1]) > 0.5);
                     *      if (!isSimilar) continue;
                     *      await variant.ClickAsync();
                     *      break;
                     *  }
                     * }
                     */
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
                finally
                {
                    await PptrUtils.CloseAsync();
                }
            }
        }
Пример #7
0
        static async Task Main()
        {
            foreach (string profileName in GenshinSharedUtils.ProfileNames)
            {
                try
                {
                    Console.WriteLine(profileName);

                    /* Start up a chromium */
                    PptrUtils.LoadExtension("padekgcemlokbadohgkifijomclgjgif");
                    PptrUtils.LoadExtension("ajhmfdgkijocedmfjonnpjfojldioehi");
                    PptrUtils.LoadExtension("cjpalhdlnbpafiamejdnhcphjbkeiagm");
                    PptrUtils.ProfilePath = Paths.GetChromiumUserDataDir(profileName);
                    _page = PptrUtils.Page;

                    /* Open the page */
                    var url = "https://webstatic-sea.mihoyo.com/ys/event/signin-sea/index.html?act_id=e202102251931481&lang=ru-ru";
                    await _page.GoToAsync(url, 999999, new [] { WaitUntilNavigation.Load });

                    System.Threading.Thread.Sleep(15300); //wait error message disappear

                    await GenshinSharedUtils.CheckAuth(_page);

                    /* Search active item */
                    await _page.WaitForSelectorAsync(
                        "div[class^='components-home-assets-__sign-content_---item---']",
                        PptrUtils.ShortSelectorAwaiter
                        );

                    var divs = await _page.QuerySelectorAllAsync("div");

                    foreach (var div in divs)
                    {
                        var classNameProperty = await div.GetPropertyAsync("className");

                        var className = classNameProperty.ToString();
                        if (!className.Contains("components-home-assets-__sign-content_---item---"))
                        {
                            continue;
                        }
                        if (!className.Contains("components-home-assets-__sign-content_---active---"))
                        {
                            continue;
                        }
                        await div.ClickAsync();
                    }

                    /* Search form close button */
                    await _page.WaitForSelectorAsync(
                        "div[class^='components-common-common-dialog-__index_---btn---']",
                        PptrUtils.LongSelectorAwaiter
                        );

                    divs = await _page.QuerySelectorAllAsync("div");

                    foreach (var div in divs)
                    {
                        var classNameProperty = await div.GetPropertyAsync("className");

                        var className = classNameProperty.ToString();
                        if (!className.Contains("components-common-common-dialog-__index_---btn---"))
                        {
                            continue;
                        }
                        if (!className.Contains("components-common-common-dialog-__index_---btn__left---"))
                        {
                            continue;
                        }
                        await div.ClickAsync();
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
                finally
                {
                    await PptrUtils.CloseAsync();
                }
            }

            Console.WriteLine("Bye!");
        }
Пример #8
0
        public static async Task Run()
        {
            foreach (string profileName in GenshinSharedUtils.ProfileNames)
            {
                try
                {
                    Console.WriteLine("Profile: " + profileName);

                    var profilePath = Paths.GetChromiumUserDataDir(profileName);
                    PptrUtils.ProfilePath = profilePath;
                    _page = PptrUtils.Page;

                    const string url = "https://webstatic-sea.mihoyo.com/ys/event/e20211203-album/index.html";
                    await _page.GoToAsync(url, WaitUntilNavigation.Load);

                    if (!await GenshinSharedUtils.CheckAuth(_page))
                    {
                        throw new Exception("Auth problem!");
                    }

                    Thread.Sleep(30000); /* wait animation */

                    await PptrUtils.WaitAndClick("div.main-button.main-button__left", PptrUtils.LongSelectorAwaiter);

                    Thread.Sleep(3000);

                    ElementHandle[] dayDivs = (await _page.QuerySelectorAllAsync("div"))
                                              .Where(div => div.EvaluateFunctionAsync <string>("e => e.className").Result.Contains("day-list-item"))
                                              .ToArray();

                    foreach (ElementHandle dayDiv in dayDivs)
                    {
                        await dayDiv.ClickAsync();

                        Thread.Sleep(1000);

                        ElementHandle[] getDivs = (await _page.QuerySelectorAllAsync("div"))
                                                  .Where(div => div.EvaluateFunctionAsync <string>("e => e.innerHTML").Result == "Получить")
                                                  .ToArray();

                        foreach (ElementHandle getDiv in getDivs)
                        {
                            await getDiv.ClickAsync();

                            Thread.Sleep(1000);
                        }
                    }

                    _page.QuerySelectorAsync("div[class^='components-topNav-assets-__topNav_---close-btn---']").Result
                    .ClickAsync().GetAwaiter().GetResult();
                    Thread.Sleep(3000);

                    await PptrUtils.WaitAndClick("div.main-button.main-button__right", PptrUtils.LongSelectorAwaiter);

                    Thread.Sleep(3000);

                    (await _page.QuerySelectorAllAsync("div"))
                    .FirstOrDefault(div => div.EvaluateFunctionAsync <string>("e => e.innerHTML").Result == "Отмена")
                    ?.ClickAsync().GetAwaiter().GetResult();
                    Thread.Sleep(1000);

                    await PptrUtils.WaitAndClick("div.button-spot__progress", PptrUtils.LongSelectorAwaiter);

                    Thread.Sleep(3000);

                    ElementHandle[] awardIcons = await _page.QuerySelectorAllAsync("div[class^='components-award-assets-__award_---icon---'");

                    foreach (ElementHandle awardIcon in awardIcons)
                    {
                        await awardIcon.ClickAsync();

                        Thread.Sleep(1000);

                        //grab award
                        (await _page.QuerySelectorAllAsync("div"))
                        .FirstOrDefault(div => div.EvaluateFunctionAsync <string>("e => e.innerHTML").Result == "Получить")
                        ?.ClickAsync().GetAwaiter().GetResult();
                        Thread.Sleep(1000);
                        await PptrUtils.ClickIfExists("div[class^='components-result-assets-__result_---click-close---'");
                    }

                    Console.WriteLine("debug");
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
                finally
                {
                    await PptrUtils.CloseAsync();
                }
            }
        }
Пример #9
0
        static async Task Main(string[] args)
        {
            try
            {
                var wikiCodes = await GrabCodesFandomWiki();

                args = args.Union(wikiCodes).ToArray();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            try
            {
                var reactorCodes = await GrabCodesJoyReactor();

                args = args.Union(reactorCodes).ToArray();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            if (args.Length == 0)
            {
                Console.WriteLine("No codes!");
                return;
            }

            foreach (string profileName in GenshinSharedUtils.ProfileNames)
            {
                Console.WriteLine("Profile: " + profileName);

                try
                {
                    PptrUtils.ProfilePath = Paths.GetChromiumUserDataDir(profileName);
                    _page = PptrUtils.Page;

                    var url = "https://genshin.mihoyo.com/ru/gift";
                    await _page.GoToAsync(url, WaitUntilNavigation.Load);

                    Thread.Sleep(15300); /* wait full scripts load */

                    /* Close cookie warning */
                    var cookieTipButton = await _page.QuerySelectorAsync(".mihoyo-cookie-tips > div");

                    if (cookieTipButton != null)
                    {
                        await cookieTipButton.ClickAsync();
                    }

                    await GenshinSharedUtils.CheckAuth(_page);

                    /* Select proper region */
                    var regionSelectorScript = await File.ReadAllTextAsync(
                        Path.Combine(
                            AppDomain.CurrentDomain.BaseDirectory,
                            "scripts",
                            "region_selector.js"
                            )
                        );

                    await _page.EvaluateExpressionAsync <bool>(regionSelectorScript);

                    Thread.Sleep(5310);

                    foreach (string code in args)
                    {
                        Console.WriteLine("Activating code: " + code);

                        /* Type promo code */
                        await _page.FocusAsync("#cdkey__code");

                        await _page.Keyboard.DownAsync("Control");

                        await _page.Keyboard.PressAsync("A");

                        await _page.Keyboard.UpAsync("Control");

                        await _page.Keyboard.PressAsync("Backspace");

                        await _page.Keyboard.TypeAsync(code);

                        Thread.Sleep(1111);

                        /* Submit */
                        await _page.ClickAsync("button.cdkey-form__submit");

                        try
                        {
                            await _page.WaitForSelectorAsync(".cdkey-result__container");

                            string resultMessage = await _page.EvaluateExpressionAsync <string>("document.querySelector('.cdkey-result__message').innerText");

                            Console.WriteLine(resultMessage);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine("Result container not appeared");
                        }

                        Thread.Sleep(5310);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
                finally
                {
                    await PptrUtils.CloseAsync();
                }
            }
        }
        public static async Task Run()
        {
            await GrabAnswers();

            foreach (string profileName in GenshinSharedUtils.ProfileNames)
            {
                try
                {
                    Console.WriteLine("Profile: " + profileName);

                    var profilePath = Paths.GetChromiumUserDataDir(profileName);
                    PptrUtils.ProfilePath = profilePath;
                    _page = PptrUtils.Page;

                    const string url = "https://webstatic-sea.hoyoverse.com/ys/event/answer-question/index.html?activity_no=2f151b0c13924d49#";
                    await _page.GoToAsync(url, WaitUntilNavigation.Load);

                    Thread.Sleep(5310); //wait error message disappear

                    // if (!await GenshinSharedUtils.CheckAuth(_page)) throw new Exception("Auth problem!");

                    await PptrUtils.ClickIfExists("p.top-btn-title");

                    const string questionSelector = "p[class^='components-game-assets-qa-info___title--'] p[class^='components-game-assets-qa-info___text--']";
                    const string variantsSelector = "div[class^='components-game-assets-qa-info___options-item--'][class^='components-game-assets-qa-info___options-']";
                    var          variantCleaner   = new Regex(@"^[A-Z]+\.\s");

                    for (int i = 0; i < 11; i++)
                    {
                        Thread.Sleep(3555); //wait animation

                        var questionTag = await _page.QuerySelectorAsync(questionSelector);

                        if (questionTag == null)
                        {
                            continue;
                        }
                        var questionText = await questionTag.EvaluateFunctionAsync <string>("e => e.innerText");

                        questionText = ProcessString(questionText);

                        var answers = QaDict.Where(qa => qa[0] == questionText).ToList();

                        if (answers.Count == 0)
                        {
                            #if (DEBUG)
                            Console.WriteLine("Unknown question: " + questionText);
                            #endif

                            #if (!DEBUG)
                            throw new Exception("Unknown question: " + questionText);
                            #endif
                        }

                        var variants = await _page.QuerySelectorAllAsync(variantsSelector);

                        bool answered = false;
                        foreach (var variant in variants)
                        {
                            var variantText = await variant.EvaluateFunctionAsync <string>("e => e.innerText");

                            variantText = variantCleaner.Replace(variantText, "");
                            variantText = ProcessString(variantText);
                            bool isRight = answers.Any(qa => qa[1] == variantText);
                            if (!isRight)
                            {
                                continue;
                            }
                            answered = true;
                            await variant.ClickAsync();

                            break;
                        }
                        if (answered)
                        {
                            continue;
                        }
                        foreach (var variant in variants)
                        {
                            var variantText = await variant.EvaluateFunctionAsync <string>("e => e.innerText");

                            variantText = variantCleaner.Replace(variantText, "");
                            variantText = ProcessString(variantText);
                            bool isSimilar = answers.Any(qa => CalculateSimilarity(variantText, qa[1]) > 0.5);
                            if (!isSimilar)
                            {
                                continue;
                            }
                            await variant.ClickAsync();

                            break;
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
                finally
                {
                    await PptrUtils.CloseAsync();
                }
            }
        }