options: store-specific logins, drop SCREEN_
This commit is contained in:
parent
577fd84a7c
commit
792b4b3915
6 changed files with 25 additions and 23 deletions
|
|
@ -52,9 +52,9 @@ EXPOSE 5900
|
||||||
EXPOSE 6080
|
EXPOSE 6080
|
||||||
|
|
||||||
# Configure Xvfb via environment variables:
|
# Configure Xvfb via environment variables:
|
||||||
ENV SCREEN_WIDTH 1280
|
ENV WIDTH 1280
|
||||||
ENV SCREEN_HEIGHT 1280
|
ENV HEIGHT 1280
|
||||||
ENV SCREEN_DEPTH 24
|
ENV DEPTH 24
|
||||||
|
|
||||||
# Show browser instead of running headless
|
# Show browser instead of running headless
|
||||||
ENV SHOW 1
|
ENV SHOW 1
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,8 @@ The available options/variables and their default values are:
|
||||||
| Option | Default | Description |
|
| Option | Default | Description |
|
||||||
|--------------- |--------- |------------------------------------------------------------------------ |
|
|--------------- |--------- |------------------------------------------------------------------------ |
|
||||||
| SHOW | 1 | Show browser if 1. Default for Docker, not shown when running outside. |
|
| SHOW | 1 | Show browser if 1. Default for Docker, not shown when running outside. |
|
||||||
| SCREEN_WIDTH | 1280 | Width of the opened browser (and screen vor VNC in Docker). |
|
| WIDTH | 1280 | Width of the opened browser (and screen vor VNC in Docker). |
|
||||||
| SCREEN_HEIGHT | 1280 | Height of the opened browser (and screen vor VNC in Docker). |
|
| HEIGHT | 1280 | Height of the opened browser (and screen vor VNC in Docker). |
|
||||||
| VNC_PASSWORD | | VNC password for Docker. No password used by default! |
|
| VNC_PASSWORD | | VNC password for Docker. No password used by default! |
|
||||||
| EMAIL | | Default email for any login. |
|
| EMAIL | | Default email for any login. |
|
||||||
| PASSWORD | | Default password for any login. |
|
| PASSWORD | | Default password for any login. |
|
||||||
|
|
@ -62,6 +62,8 @@ The available options/variables and their default values are:
|
||||||
| EG_PASSWORD | | Epic Games password for login. Overrides PASSWORD. |
|
| EG_PASSWORD | | Epic Games password for login. Overrides PASSWORD. |
|
||||||
| PG_EMAIL | | Prime Gaming email for login. Overrides EMAIL. |
|
| PG_EMAIL | | Prime Gaming email for login. Overrides EMAIL. |
|
||||||
| PG_PASSWORD | | Prime Gaming password for login. Overrides PASSWORD. |
|
| PG_PASSWORD | | Prime Gaming password for login. Overrides PASSWORD. |
|
||||||
|
| GOG_EMAIL | | GOG email for login. Overrides EMAIL. |
|
||||||
|
| GOG_PASSWORD | | GOG password for login. Overrides PASSWORD. |
|
||||||
|
|
||||||
#### Other ways to set options
|
#### Other ways to set options
|
||||||
On Linux/macOS you can prefix the variables you want to set, for example `EMAIL=foo@bar.baz SHOW=1 node epic-games` will show the browser and skip asking you for your login email.
|
On Linux/macOS you can prefix the variables you want to set, for example `EMAIL=foo@bar.baz SHOW=1 node epic-games` will show the browser and skip asking you for your login email.
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,8 @@ rm -f /tmp/.X1-lock
|
||||||
# −screen NUM WxHxD creates the screen and sets its width, height, and depth
|
# −screen NUM WxHxD creates the screen and sets its width, height, and depth
|
||||||
|
|
||||||
export DISPLAY=:1 # need to export this, otherwise playwright complains with 'Looks like you launched a headed browser without having a XServer running.'
|
export DISPLAY=:1 # need to export this, otherwise playwright complains with 'Looks like you launched a headed browser without having a XServer running.'
|
||||||
Xvfb $DISPLAY -ac -screen 0 "${SCREEN_WIDTH}x${SCREEN_HEIGHT}x${SCREEN_DEPTH}" &
|
Xvfb $DISPLAY -ac -screen 0 "${WIDTH}x${HEIGHT}x${DEPTH}" &
|
||||||
echo "Xvfb display server created screen with resolution ${SCREEN_WIDTH}x${SCREEN_HEIGHT}"
|
echo "Xvfb display server created screen with resolution ${WIDTH}x${HEIGHT}"
|
||||||
x11vnc -display $DISPLAY -forever -shared -rfbport $VNC_PORT -bg -nopw 2>/dev/null 1>&2 # -passwd "${VNC_PASSWORD}"
|
x11vnc -display $DISPLAY -forever -shared -rfbport $VNC_PORT -bg -nopw 2>/dev/null 1>&2 # -passwd "${VNC_PASSWORD}"
|
||||||
echo "VNC is running on port $VNC_PORT (no password!)"
|
echo "VNC is running on port $VNC_PORT (no password!)"
|
||||||
websockify -D --web "/usr/share/novnc/" $NOVNC_PORT "localhost:$VNC_PORT" 2>/dev/null 1>&2 &
|
websockify -D --web "/usr/share/novnc/" $NOVNC_PORT "localhost:$VNC_PORT" 2>/dev/null 1>&2 &
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ const headless = !debug && !show;
|
||||||
const URL_CLAIM = 'https://store.epicgames.com/en-US/free-games';
|
const URL_CLAIM = 'https://store.epicgames.com/en-US/free-games';
|
||||||
const URL_LOGIN = 'https://www.epicgames.com/id/login?lang=en-US&noHostRedirect=true&redirectUrl=' + URL_CLAIM;
|
const URL_LOGIN = 'https://www.epicgames.com/id/login?lang=en-US&noHostRedirect=true&redirectUrl=' + URL_CLAIM;
|
||||||
const TIMEOUT = 20 * 1000; // 20s, default is 30s
|
const TIMEOUT = 20 * 1000; // 20s, default is 30s
|
||||||
const SCREEN_WIDTH = Number(process.env.SCREEN_WIDTH) || 1280;
|
const WIDTH = Number(process.env.WIDTH) || 1280;
|
||||||
const SCREEN_HEIGHT = Number(process.env.SCREEN_HEIGHT) || 1280;
|
const HEIGHT = Number(process.env.HEIGHT) || 1280;
|
||||||
|
|
||||||
console.log(datetime(), 'started checking epic-games');
|
console.log(datetime(), 'started checking epic-games');
|
||||||
|
|
||||||
|
|
@ -41,7 +41,7 @@ const context = await firefox.launchPersistentContext(dirs.browser, {
|
||||||
// chrome will not work in linux arm64, only chromium
|
// chrome will not work in linux arm64, only chromium
|
||||||
// channel: 'chrome', // https://playwright.dev/docs/browsers#google-chrome--microsoft-edge
|
// channel: 'chrome', // https://playwright.dev/docs/browsers#google-chrome--microsoft-edge
|
||||||
headless,
|
headless,
|
||||||
viewport: { width: SCREEN_WIDTH, height: SCREEN_HEIGHT },
|
viewport: { width: WIDTH, height: HEIGHT },
|
||||||
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.83 Safari/537.36', // see replace of Headless in util.newStealthContext. TODO Windows UA enough to avoid 'device not supported'? update if browser is updated?
|
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.83 Safari/537.36', // see replace of Headless in util.newStealthContext. TODO Windows UA enough to avoid 'device not supported'? update if browser is updated?
|
||||||
// userAgent for firefox: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Firefox/106.0
|
// userAgent for firefox: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Firefox/106.0
|
||||||
locale: "en-US", // ignore OS locale to be sure to have english text for locators
|
locale: "en-US", // ignore OS locale to be sure to have english text for locators
|
||||||
|
|
@ -78,8 +78,8 @@ try {
|
||||||
await page.goto(URL_LOGIN, { waitUntil: 'domcontentloaded' });
|
await page.goto(URL_LOGIN, { waitUntil: 'domcontentloaded' });
|
||||||
|
|
||||||
console.info('Press ESC to skip if you want to login in the browser.');
|
console.info('Press ESC to skip if you want to login in the browser.');
|
||||||
const email = process.env.EMAIL || await prompt({message: 'Enter email'});
|
const email = process.env.EG_EMAIL || process.env.EMAIL || await prompt({message: 'Enter email'});
|
||||||
const password = process.env.PASSWORD || await prompt({type: 'password', message: 'Enter password'});
|
const password = process.env.EG_PASSWORD || process.env.PASSWORD || await prompt({type: 'password', message: 'Enter password'});
|
||||||
if (email && password) {
|
if (email && password) {
|
||||||
await page.click('text=Sign in with Epic Games');
|
await page.click('text=Sign in with Epic Games');
|
||||||
await page.fill('#email', email);
|
await page.fill('#email', email);
|
||||||
|
|
|
||||||
12
gog.js
12
gog.js
|
|
@ -12,9 +12,9 @@ const show = process.argv.includes('show', 2);
|
||||||
const headless = !debug && !show;
|
const headless = !debug && !show;
|
||||||
|
|
||||||
const URL_CLAIM = 'https://www.gog.com/en';
|
const URL_CLAIM = 'https://www.gog.com/en';
|
||||||
const TIMEOUT = 0 * 1000; // 20s, default is 30s
|
const TIMEOUT = 20 * 1000; // 20s, default is 30s
|
||||||
const SCREEN_WIDTH = Number(process.env.SCREEN_WIDTH) || 1280;
|
const WIDTH = Number(process.env.WIDTH) || 1280;
|
||||||
const SCREEN_HEIGHT = Number(process.env.SCREEN_HEIGHT) || 1280;
|
const HEIGHT = Number(process.env.HEIGHT) || 1280;
|
||||||
|
|
||||||
console.log(datetime(), 'started checking gog');
|
console.log(datetime(), 'started checking gog');
|
||||||
|
|
||||||
|
|
@ -24,7 +24,7 @@ db.data ||= {};
|
||||||
// https://playwright.dev/docs/auth#multi-factor-authentication
|
// https://playwright.dev/docs/auth#multi-factor-authentication
|
||||||
const context = await firefox.launchPersistentContext(dirs.browser, {
|
const context = await firefox.launchPersistentContext(dirs.browser, {
|
||||||
headless,
|
headless,
|
||||||
viewport: { width: SCREEN_WIDTH, height: SCREEN_HEIGHT },
|
viewport: { width: WIDTH, height: HEIGHT },
|
||||||
locale: "en-US", // ignore OS locale to be sure to have english text for locators -> done via /en in URL
|
locale: "en-US", // ignore OS locale to be sure to have english text for locators -> done via /en in URL
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -48,8 +48,8 @@ try {
|
||||||
const iframe = page.frameLocator('#GalaxyAccountsFrameContainer iframe');
|
const iframe = page.frameLocator('#GalaxyAccountsFrameContainer iframe');
|
||||||
if (!debug) context.setDefaultTimeout(0); // give user time to log in without timeout
|
if (!debug) context.setDefaultTimeout(0); // give user time to log in without timeout
|
||||||
console.info('Press ESC to skip if you want to login in the browser (not possible in headless mode).');
|
console.info('Press ESC to skip if you want to login in the browser (not possible in headless mode).');
|
||||||
const email = process.env.EMAIL || await prompt({message: 'Enter email'});
|
const email = process.env.GOG_EMAIL || process.env.EMAIL || await prompt({message: 'Enter email'});
|
||||||
const password = process.env.PASSWORD || await prompt({type: 'password', message: 'Enter password'});
|
const password = process.env.GOG_PASSWORD || process.env.PASSWORD || await prompt({type: 'password', message: 'Enter password'});
|
||||||
if (email && password) {
|
if (email && password) {
|
||||||
iframe.locator('a[href="/logout"]').click().catch(_ => { }); // Click 'Change account' (email from previous login is set in some cookie)
|
iframe.locator('a[href="/logout"]').click().catch(_ => { }); // Click 'Change account' (email from previous login is set in some cookie)
|
||||||
await iframe.locator('#login_username').fill(email);
|
await iframe.locator('#login_username').fill(email);
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ const headless = !debug && !show;
|
||||||
// const URL_LOGIN = 'https://www.amazon.de/ap/signin'; // wrong. needs some session args to be valid?
|
// const URL_LOGIN = 'https://www.amazon.de/ap/signin'; // wrong. needs some session args to be valid?
|
||||||
const URL_CLAIM = 'https://gaming.amazon.com/home';
|
const URL_CLAIM = 'https://gaming.amazon.com/home';
|
||||||
const TIMEOUT = 20 * 1000; // 20s, default is 30s
|
const TIMEOUT = 20 * 1000; // 20s, default is 30s
|
||||||
const SCREEN_WIDTH = Number(process.env.SCREEN_WIDTH) || 1280;
|
const WIDTH = Number(process.env.WIDTH) || 1280;
|
||||||
const SCREEN_HEIGHT = Number(process.env.SCREEN_HEIGHT) || 1280;
|
const HEIGHT = Number(process.env.HEIGHT) || 1280;
|
||||||
|
|
||||||
console.log(datetime(), 'started checking prime-gaming');
|
console.log(datetime(), 'started checking prime-gaming');
|
||||||
|
|
||||||
|
|
@ -34,7 +34,7 @@ const migrateDb = (user) => {
|
||||||
// https://playwright.dev/docs/auth#multi-factor-authentication
|
// https://playwright.dev/docs/auth#multi-factor-authentication
|
||||||
const context = await firefox.launchPersistentContext(dirs.browser, {
|
const context = await firefox.launchPersistentContext(dirs.browser, {
|
||||||
headless,
|
headless,
|
||||||
viewport: { width: SCREEN_WIDTH, height: SCREEN_HEIGHT },
|
viewport: { width: WIDTH, height: HEIGHT },
|
||||||
locale: "en-US", // ignore OS locale to be sure to have english text for locators
|
locale: "en-US", // ignore OS locale to be sure to have english text for locators
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -56,8 +56,8 @@ try {
|
||||||
await page.click('button:has-text("Sign in")');
|
await page.click('button:has-text("Sign in")');
|
||||||
if (!debug) context.setDefaultTimeout(0); // give user time to log in without timeout
|
if (!debug) context.setDefaultTimeout(0); // give user time to log in without timeout
|
||||||
console.info('Press ESC to skip if you want to login in the browser (not possible in default headless mode).');
|
console.info('Press ESC to skip if you want to login in the browser (not possible in default headless mode).');
|
||||||
const email = process.env.EMAIL || await prompt({message: 'Enter email'});
|
const email = process.env.PG_EMAIL || process.env.EMAIL || await prompt({message: 'Enter email'});
|
||||||
const password = process.env.PASSWORD || await prompt({type: 'password', message: 'Enter password'});
|
const password = process.env.PG_PASSWORD || process.env.PASSWORD || await prompt({type: 'password', message: 'Enter password'});
|
||||||
if (email && password) {
|
if (email && password) {
|
||||||
await page.fill('[name=email]', email);
|
await page.fill('[name=email]', email);
|
||||||
await page.fill('[name=password]', password);
|
await page.fill('[name=password]', password);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue