check if logged in
This commit is contained in:
parent
83a4b064bd
commit
a8e8354bf7
1 changed files with 6 additions and 2 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
const { existsSync } = require('fs');
|
const { existsSync } = require('fs');
|
||||||
if (!existsSync('auth.json')) {
|
if (!existsSync('auth.json')) {
|
||||||
console.error('Missing auth.json! Run `npm login` to login and create this file by closing the opened browser.');
|
console.error('Missing auth.json! Run `npm login` to login and create this file by closing the opened browser.');
|
||||||
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { chromium } = require('playwright'); // stealth plugin needs no outdated playwright-extra
|
const { chromium } = require('playwright'); // stealth plugin needs no outdated playwright-extra
|
||||||
|
|
@ -31,7 +32,7 @@ const newStealthContext = async (browser, contextOptions = {}) => {
|
||||||
'webgl.vendor',
|
'webgl.vendor',
|
||||||
'window.outerdimensions'
|
'window.outerdimensions'
|
||||||
];
|
];
|
||||||
const evasions = enabledEvasions.map(e => new require(`puppeteer-extra-plugin-stealth/evasions/${e}`));
|
const evasions = enabledEvasions.map(e => require(`puppeteer-extra-plugin-stealth/evasions/${e}`));
|
||||||
const stealth = {
|
const stealth = {
|
||||||
callbacks: [],
|
callbacks: [],
|
||||||
async evaluateOnNewDocument(...args) {
|
async evaluateOnNewDocument(...args) {
|
||||||
|
|
@ -59,8 +60,11 @@ const newStealthContext = async (browser, contextOptions = {}) => {
|
||||||
context.setDefaultTimeout(10000);
|
context.setDefaultTimeout(10000);
|
||||||
const page = await context.newPage();
|
const page = await context.newPage();
|
||||||
await page.goto('https://www.epicgames.com/store/en-US/free-games');
|
await page.goto('https://www.epicgames.com/store/en-US/free-games');
|
||||||
// await expect(page.locator('a[role="button"]:has-text("Sign In")')).toHaveCount(0);
|
|
||||||
await page.click('button:has-text("Accept All Cookies")'); // to not waste screen space in --debug
|
await page.click('button:has-text("Accept All Cookies")'); // to not waste screen space in --debug
|
||||||
|
if (await page.locator('a[role="button"]:has-text("Sign In")').count() > 0) {
|
||||||
|
console.error('Not signed in anymore. Run `npm login` to login again.');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
// click on banner to go to current free game. TODO what if there are multiple games?
|
// click on banner to go to current free game. TODO what if there are multiple games?
|
||||||
await page.click('[data-testid="offer-card-image-landscape"]');
|
await page.click('[data-testid="offer-card-image-landscape"]');
|
||||||
const game = await page.locator('h1 div').first().innerText();
|
const game = await page.locator('h1 div').first().innerText();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue