Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try puppeteer-hcaptcha for solving in headless mode #8

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion epic-games.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,24 @@ import path from 'path';
import { __dirname, stealth } from './util.js';
const debug = process.env.PWDEBUG == '1'; // runs non-headless and opens https://playwright.dev/docs/inspector

import { hcaptcha } from "puppeteer-hcaptcha";

const URL_LOGIN = 'https://www.epicgames.com/login';
const URL_CLAIM = 'https://www.epicgames.com/store/en-US/free-games';
const TIMEOUT = 20 * 1000; // 20s, default is 30s

// https://playwright.dev/docs/auth#multi-factor-authentication
const context = await chromium.launchPersistentContext(path.resolve(__dirname, 'userDataDir'), {
channel: 'chrome', // https://playwright.dev/docs/browsers#google-chrome--microsoft-edge
headless: false,
headless: true,
viewport: { width: 1280, height: 1280 },
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36', // see replace of Headless in util.newStealthContext. TODO update if browser is updated!
locale: "en-US", // ignore OS locale to be sure to have english text for locators
args: [ // don't want to see bubble 'Restore pages? Chrome didn't shut down correctly.', but flags below don't work.
'--disable-session-crashed-bubble',
'--restore-last-session',
"--disable-dev-shm-usage",
"--disable-web-security",
],
});

Expand Down Expand Up @@ -94,6 +98,8 @@ for (let i=1; i<=n; i++) {
// process.exit(1);
// }
// await page.waitForTimeout(3000);
// <iframe class="" src="/store/purchase?highlightColor=0078f2&amp;offers=1-e...&amp;orderId&amp;purchaseToken&amp;showNavigation=true"></iframe>
await hcaptcha(page.frame({ url: /.*\/store\/purchase.*/ }).page()); // TODO Timeout waiting for selector "iframe[src*="newassets.hcaptcha.com"]" to be visible
await page.waitForSelector('text=Thank you for buying'); // EU: wait, non-EU: wait again
console.log('Claimed successfully!');
} catch (e) {
Expand Down