From 85c4cc84ef65e5c1ac3ea09eb55060ecc7533014 Mon Sep 17 00:00:00 2001 From: jamb <38476314+JambDev@users.noreply.github.com> Date: Mon, 24 Jul 2023 00:59:54 -0400 Subject: [PATCH] Bypass mature content warning with cookie Adds "HasAcceptedAgeGates" cookie identical to how Epic adds it. Also comments out the section that would automatically press Continue button upon seeing mature content warning. --- epic-games.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/epic-games.js b/epic-games.js index 314b349..42f39b4 100644 --- a/epic-games.js +++ b/epic-games.js @@ -60,7 +60,7 @@ let user; try { await context.addCookies([{name: 'OptanonAlertBoxClosed', value: new Date(Date.now() - 5*24*60*60*1000).toISOString(), domain: '.epicgames.com', path: '/'}]); // Accept cookies to get rid of banner to save space on screen. Set accept time to 5 days ago. - + await context.addCookies([{name: 'HasAcceptedAgeGates', value: "ESRB%3A9007199254740991", domain: '.epicgames.com', path: '/'}]); // Bypass mature content warning await page.goto(URL_CLAIM, { waitUntil: 'domcontentloaded' }); // 'domcontentloaded' faster than default 'load' https://playwright.dev/docs/api/class-page#page-goto // page.click('button:has-text("Accept All Cookies")').catch(_ => { }); // Not needed anymore since we set the cookie above. Clicking this did not always work since the message was animated in too slowly. @@ -124,11 +124,12 @@ try { const btnText = await page.locator('//button[@data-testid="purchase-cta-button"][not(contains(.,"Loading"))]').first().innerText(); // barrier to block until page is loaded // click Continue if 'This game contains mature content recommended only for ages 18+' - if (await page.locator('button:has-text("Continue")').count() > 0) { + // HasAcceptedAgeGates cookie gets rid of the need for this + /*if (await page.locator('button:has-text("Continue")').count() > 0) { console.log(' This game contains mature content recommended only for ages 18+'); await page.click('button:has-text("Continue")', { delay: 111 }); await page.waitForTimeout(2000); - } + }*/ const title = await page.locator('h1').first().innerText(); const game_id = page.url().split('/').pop();