From 44d712e333c6952d4aadc6a9a7b4865a4511227b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Sep 2023 09:41:42 +0200 Subject: [PATCH 01/10] build(deps): bump actions/checkout from 3 to 4 (#207) Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index bf7fc06..f80650c 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -19,7 +19,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set environment variables run: | From 30db49d9b92f997b75644b43ff3c28f7f2ccd27a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Sep 2023 09:49:00 +0200 Subject: [PATCH 02/10] build(deps): bump docker/setup-qemu-action from 2 to 3 (#215) Bumps [docker/setup-qemu-action](https://github.com/docker/setup-qemu-action) from 2 to 3. - [Release notes](https://github.com/docker/setup-qemu-action/releases) - [Commits](https://github.com/docker/setup-qemu-action/compare/v2...v3) --- updated-dependencies: - dependency-name: docker/setup-qemu-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f80650c..2ddc409 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -27,7 +27,7 @@ jobs: echo "NOW=$(date -R)" >> $GITHUB_ENV # date -Iseconds; date +'%Y-%m-%dT%H:%M:%S' - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 From 6cdef56c094b860c633c40abb5e37b8f1ab21b60 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Sep 2023 09:50:04 +0200 Subject: [PATCH 03/10] build(deps): bump docker/setup-buildx-action from 2 to 3 (#213) Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 2 to 3. - [Release notes](https://github.com/docker/setup-buildx-action/releases) - [Commits](https://github.com/docker/setup-buildx-action/compare/v2...v3) --- updated-dependencies: - dependency-name: docker/setup-buildx-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 2ddc409..a493dc2 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -30,7 +30,7 @@ jobs: uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Login to Docker Hub uses: docker/login-action@v2 From 0ba693eeb6dbe210ad829189d2142c2e125e27da Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Sep 2023 09:51:23 +0200 Subject: [PATCH 04/10] build(deps): bump docker/login-action from 2 to 3 (#214) Bumps [docker/login-action](https://github.com/docker/login-action) from 2 to 3. - [Release notes](https://github.com/docker/login-action/releases) - [Commits](https://github.com/docker/login-action/compare/v2...v3) --- updated-dependencies: - dependency-name: docker/login-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a493dc2..1cfe5b2 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -33,14 +33,14 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3 # if: ${{ secrets.DOCKERHUB_USERNAME && secrets.DOCKERHUB_TOKEN }} with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Login to GitHub Container Registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} From 2a4da3f49cfec3e72ad543727bca50e4f136f3a5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Sep 2023 09:51:53 +0200 Subject: [PATCH 05/10] build(deps): bump docker/build-push-action from 4 to 5 (#212) Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 4 to 5. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v4...v5) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 1cfe5b2..25470d5 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -47,7 +47,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 with: context: . push: true From 1fbabbc0f2ad5f44e8265a98b7b6d949e2256e6a Mon Sep 17 00:00:00 2001 From: Ralf Vogler Date: Mon, 18 Sep 2023 12:49:23 +0200 Subject: [PATCH 06/10] log path of recorded video --- epic-games.js | 1 + gog.js | 1 + prime-gaming.js | 1 + unrealengine.js | 1 + 4 files changed, 4 insertions(+) diff --git a/epic-games.js b/epic-games.js index 1ab81c6..56c1035 100644 --- a/epic-games.js +++ b/epic-games.js @@ -259,4 +259,5 @@ try { } } if (cfg.debug) writeFileSync(path.resolve(cfg.dir.browser, 'cookies.json'), JSON.stringify(await context.cookies())); +if (page.video()) console.log('Recorded video:', await page.video().path()) await context.close(); diff --git a/gog.js b/gog.js index fa82c8a..6b02ee5 100644 --- a/gog.js +++ b/gog.js @@ -145,4 +145,5 @@ try { notify(`gog (${user}):
${html_game_list(notify_games)}`); } } +if (page.video()) console.log('Recorded video:', await page.video().path()) await context.close(); diff --git a/prime-gaming.js b/prime-gaming.js index 1162496..1523e5f 100644 --- a/prime-gaming.js +++ b/prime-gaming.js @@ -387,4 +387,5 @@ try { notify(`prime-gaming (${user}):
${html_game_list(notify_games)}`); } } +if (page.video()) console.log('Recorded video:', await page.video().path()) await context.close(); diff --git a/unrealengine.js b/unrealengine.js index 4370a85..a5d3282 100644 --- a/unrealengine.js +++ b/unrealengine.js @@ -199,4 +199,5 @@ try { } } if (cfg.debug) writeFileSync(path.resolve(cfg.dir.browser, 'cookies.json'), JSON.stringify(await context.cookies())); +if (page.video()) console.log('Recorded video:', await page.video().path()) await context.close(); From b748460b731bd565592e1c68c01a2c4eca9ae1a2 Mon Sep 17 00:00:00 2001 From: Ralf Vogler Date: Mon, 18 Sep 2023 12:58:20 +0200 Subject: [PATCH 07/10] disable Playwright's handleSIGINT and close context ourselves to save recordings also on SIGINT --- epic-games.js | 8 +++++--- gog.js | 12 +++++++----- prime-gaming.js | 8 +++++--- unrealengine.js | 8 +++++--- util.js | 3 ++- 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/epic-games.js b/epic-games.js index 56c1035..e58725b 100644 --- a/epic-games.js +++ b/epic-games.js @@ -14,8 +14,6 @@ console.log(datetime(), 'started checking epic-games'); const db = await jsonDb('epic-games.json', {}); -handleSIGINT(); - if (cfg.time) console.time('startup'); // https://www.nopecha.com extension source from https://github.com/NopeCHA/NopeCHA/releases/tag/0.1.16 @@ -33,6 +31,7 @@ const context = await firefox.launchPersistentContext(cfg.dir.browser, { locale: "en-US", // ignore OS locale to be sure to have english text for locators recordVideo: cfg.record ? { dir: 'data/record/', size: { width: cfg.width, height: cfg.height } } : undefined, // will record a .webm video for each page navigated; without size, video would be scaled down to fit 800x800 recordHar: cfg.record ? { path: `data/record/eg-${datetime()}.har` } : undefined, // will record a HAR file with network requests and responses; can be imported in Chrome devtools + handleSIGINT: false, // have to handle ourselves and call context.close(), otherwise recordings from above won't be saved args: [ // https://peter.sh/experiments/chromium-command-line-switches // don't want to see bubble 'Restore pages? Chrome didn't shut down correctly.' // '--restore-last-session', // does not apply for crash/killed @@ -43,6 +42,8 @@ const context = await firefox.launchPersistentContext(cfg.dir.browser, { // ignoreDefaultArgs: ['--enable-automation'], // remove default arg that shows the info bar with 'Chrome is being controlled by automated test software.'. Since Chromeium 106 this leads to show another info bar with 'You are using an unsupported command-line flag: --no-sandbox. Stability and security will suffer.'. }); +handleSIGINT(context); + // Without stealth plugin, the website shows an hcaptcha on login with username/password and in the last step of claiming a game. It may have other heuristics like unsuccessful logins as well. After <6h (TBD) it resets to no captcha again. Getting a new IP also resets. await stealth(context); @@ -248,8 +249,9 @@ try { } if (cfg.time) console.timeEnd('claim all games'); } catch (error) { - console.error(error); // .toString()? process.exitCode ||= 1; + console.error('--- Exception:'); + console.error(error); // .toString()? if (error.message && process.exitCode != 130) notify(`epic-games failed: ${error.message.split('\n')[0]}`); } finally { diff --git a/gog.js b/gog.js index 6b02ee5..341ee6c 100644 --- a/gog.js +++ b/gog.js @@ -10,17 +10,18 @@ console.log(datetime(), 'started checking gog'); const db = await jsonDb('gog.json', {}); -handleSIGINT(); - // https://playwright.dev/docs/auth#multi-factor-authentication const context = await firefox.launchPersistentContext(cfg.dir.browser, { headless: cfg.headless, viewport: { width: cfg.width, height: cfg.height }, locale: "en-US", // ignore OS locale to be sure to have english text for locators -> done via /en in URL - // recordHar: { path: './data/gog.har' }, // https://toolbox.googleapps.com/apps/har_analyzer/ - // recordVideo: { dir: './data/videos' }, // console.log(await page.video().path()); + recordVideo: cfg.record ? { dir: 'data/record/', size: { width: cfg.width, height: cfg.height } } : undefined, // will record a .webm video for each page navigated; without size, video would be scaled down to fit 800x800 + recordHar: cfg.record ? { path: `data/record/gog-${datetime()}.har` } : undefined, // will record a HAR file with network requests and responses; can be imported in Chrome devtools + handleSIGINT: false, // have to handle ourselves and call context.close(), otherwise recordings from above won't be saved }); +handleSIGINT(context); + if (!cfg.debug) context.setDefaultTimeout(cfg.timeout); const page = context.pages().length ? context.pages()[0] : await context.newPage(); // should always exist @@ -135,8 +136,9 @@ try { } } } catch (error) { - console.error(error); // .toString()? process.exitCode ||= 1; + console.error('--- Exception:'); + console.error(error); // .toString()? if (error.message && process.exitCode != 130) notify(`gog failed: ${error.message.split('\n')[0]}`); } finally { diff --git a/prime-gaming.js b/prime-gaming.js index 1523e5f..a5df36d 100644 --- a/prime-gaming.js +++ b/prime-gaming.js @@ -12,8 +12,6 @@ console.log(datetime(), 'started checking prime-gaming'); const db = await jsonDb('prime-gaming.json', {}); -handleSIGINT(); - // https://playwright.dev/docs/auth#multi-factor-authentication const context = await firefox.launchPersistentContext(cfg.dir.browser, { headless: cfg.headless, @@ -21,8 +19,11 @@ const context = await firefox.launchPersistentContext(cfg.dir.browser, { locale: "en-US", // ignore OS locale to be sure to have english text for locators recordVideo: cfg.record ? { dir: 'data/record/', size: { width: cfg.width, height: cfg.height } } : undefined, // will record a .webm video for each page navigated; without size, video would be scaled down to fit 800x800 recordHar: cfg.record ? { path: `data/record/pg-${datetime()}.har` } : undefined, // will record a HAR file with network requests and responses; can be imported in Chrome devtools + handleSIGINT: false, // have to handle ourselves and call context.close(), otherwise recordings from above won't be saved }); +handleSIGINT(context); + // TODO test if needed await stealth(context); @@ -377,8 +378,9 @@ try { console.log('DLC: Unlinked accounts:', dlc_unlinked); } } catch (error) { - console.error(error); // .toString()? process.exitCode ||= 1; + console.error('--- Exception:'); + console.error(error); // .toString()? if (error.message && process.exitCode != 130) notify(`prime-gaming failed: ${error.message.split('\n')[0]}`); } finally { diff --git a/unrealengine.js b/unrealengine.js index a5d3282..6523503 100644 --- a/unrealengine.js +++ b/unrealengine.js @@ -17,8 +17,6 @@ console.log(datetime(), 'started checking unrealengine'); const db = await jsonDb('unrealengine.json', {}); -handleSIGINT(); - // https://playwright.dev/docs/auth#multi-factor-authentication const context = await firefox.launchPersistentContext(cfg.dir.browser, { headless: cfg.headless, @@ -28,8 +26,11 @@ const context = await firefox.launchPersistentContext(cfg.dir.browser, { locale: "en-US", // ignore OS locale to be sure to have english text for locators recordVideo: cfg.record ? { dir: 'data/record/', size: { width: cfg.width, height: cfg.height } } : undefined, // will record a .webm video for each page navigated; without size, video would be scaled down to fit 800x800 recordHar: cfg.record ? { path: `data/record/ue-${datetime()}.har` } : undefined, // will record a HAR file with network requests and responses; can be imported in Chrome devtools + handleSIGINT: false, // have to handle ourselves and call context.close(), otherwise recordings from above won't be saved }); +handleSIGINT(context); + await stealth(context); if (!cfg.debug) context.setDefaultTimeout(cfg.timeout); @@ -188,8 +189,9 @@ try { console.log('Done'); } } catch (error) { - console.error(error); // .toString()? process.exitCode ||= 1; + console.error('--- Exception:'); + console.error(error); // .toString()? if (error.message && process.exitCode != 130) notify(`unrealengine failed: ${error.message.split('\n')[0]}`); } finally { diff --git a/util.js b/util.js index 60ff4a5..94cccfd 100644 --- a/util.js +++ b/util.js @@ -27,9 +27,10 @@ export const datetimeUTC = (d = new Date()) => d.toISOString().replace('T', ' ') export const datetime = (d = new Date()) => datetimeUTC(new Date(d.getTime() - d.getTimezoneOffset() * 60000)); export const filenamify = s => s.replaceAll(':', '.').replace(/[^a-z0-9 _\-.]/gi, '_'); // alternative: https://www.npmjs.com/package/filenamify - On Unix-like systems, / is reserved. On Windows, <>:"/\|?* along with trailing periods are reserved. -export const handleSIGINT = () => process.on('SIGINT', () => { // e.g. when killed by Ctrl-C +export const handleSIGINT = (context = null) => process.on('SIGINT', async () => { // e.g. when killed by Ctrl-C console.error('\nInterrupted by SIGINT. Exit!'); // Exception shows where the script was:\n'); // killed before catch in docker... process.exitCode = 130; // 128+SIGINT to indicate to parent that process was killed + if (context) await context.close(); // in order to save recordings also on SIGINT, we need to disable Playwright's handleSIGINT and close the context ourselves }); // stealth with playwright: https://github.com/berstend/puppeteer-extra/issues/454#issuecomment-917437212 From 13b2917dd03c675d6ab9853fe188f15c52782688 Mon Sep 17 00:00:00 2001 From: Ralf Vogler Date: Mon, 18 Sep 2023 13:03:04 +0200 Subject: [PATCH 08/10] workaround for recordVideo broken in Playwright 1.36 Recording videos with relative path as in docs was broken for Firefox. Issue: https://github.com/microsoft/playwright/issues/27086 Can be reverted after PR is available in release: https://github.com/microsoft/playwright/pull/27099 --- epic-games.js | 2 +- gog.js | 3 ++- prime-gaming.js | 3 ++- unrealengine.js | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/epic-games.js b/epic-games.js index e58725b..976ce07 100644 --- a/epic-games.js +++ b/epic-games.js @@ -29,7 +29,7 @@ const context = await firefox.launchPersistentContext(cfg.dir.browser, { // userAgent firefox (macOS): Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Firefox/106.0 // userAgent firefox (docker): Mozilla/5.0 (X11; Linux aarch64; rv:109.0) Gecko/20100101 Firefox/115.0 locale: "en-US", // ignore OS locale to be sure to have english text for locators - recordVideo: cfg.record ? { dir: 'data/record/', size: { width: cfg.width, height: cfg.height } } : undefined, // will record a .webm video for each page navigated; without size, video would be scaled down to fit 800x800 + recordVideo: cfg.record ? { dir: path.resolve('data/record/'), size: { width: cfg.width, height: cfg.height } } : undefined, // will record a .webm video for each page navigated; without size, video would be scaled down to fit 800x800 recordHar: cfg.record ? { path: `data/record/eg-${datetime()}.har` } : undefined, // will record a HAR file with network requests and responses; can be imported in Chrome devtools handleSIGINT: false, // have to handle ourselves and call context.close(), otherwise recordings from above won't be saved args: [ // https://peter.sh/experiments/chromium-command-line-switches diff --git a/gog.js b/gog.js index 341ee6c..e41eed7 100644 --- a/gog.js +++ b/gog.js @@ -1,4 +1,5 @@ import { firefox } from 'playwright-firefox'; // stealth plugin needs no outdated playwright-extra +import path from 'path'; import { resolve, jsonDb, datetime, filenamify, prompt, notify, html_game_list, handleSIGINT } from './util.js'; import { cfg } from './config.js'; @@ -15,7 +16,7 @@ const context = await firefox.launchPersistentContext(cfg.dir.browser, { headless: cfg.headless, viewport: { width: cfg.width, height: cfg.height }, locale: "en-US", // ignore OS locale to be sure to have english text for locators -> done via /en in URL - recordVideo: cfg.record ? { dir: 'data/record/', size: { width: cfg.width, height: cfg.height } } : undefined, // will record a .webm video for each page navigated; without size, video would be scaled down to fit 800x800 + recordVideo: cfg.record ? { dir: path.resolve('data/record/'), size: { width: cfg.width, height: cfg.height } } : undefined, // will record a .webm video for each page navigated; without size, video would be scaled down to fit 800x800 recordHar: cfg.record ? { path: `data/record/gog-${datetime()}.har` } : undefined, // will record a HAR file with network requests and responses; can be imported in Chrome devtools handleSIGINT: false, // have to handle ourselves and call context.close(), otherwise recordings from above won't be saved }); diff --git a/prime-gaming.js b/prime-gaming.js index a5df36d..3816777 100644 --- a/prime-gaming.js +++ b/prime-gaming.js @@ -1,5 +1,6 @@ import { firefox } from 'playwright-firefox'; // stealth plugin needs no outdated playwright-extra import { authenticator } from 'otplib'; +import path from 'path'; import { resolve, jsonDb, datetime, stealth, filenamify, prompt, confirm, notify, html_game_list, handleSIGINT } from './util.js'; import { cfg } from './config.js'; @@ -17,7 +18,7 @@ const context = await firefox.launchPersistentContext(cfg.dir.browser, { headless: cfg.headless, viewport: { width: cfg.width, height: cfg.height }, locale: "en-US", // ignore OS locale to be sure to have english text for locators - recordVideo: cfg.record ? { dir: 'data/record/', size: { width: cfg.width, height: cfg.height } } : undefined, // will record a .webm video for each page navigated; without size, video would be scaled down to fit 800x800 + recordVideo: cfg.record ? { dir: path.resolve('data/record/'), size: { width: cfg.width, height: cfg.height } } : undefined, // will record a .webm video for each page navigated; without size, video would be scaled down to fit 800x800 recordHar: cfg.record ? { path: `data/record/pg-${datetime()}.har` } : undefined, // will record a HAR file with network requests and responses; can be imported in Chrome devtools handleSIGINT: false, // have to handle ourselves and call context.close(), otherwise recordings from above won't be saved }); diff --git a/unrealengine.js b/unrealengine.js index 6523503..55d4e58 100644 --- a/unrealengine.js +++ b/unrealengine.js @@ -24,7 +24,7 @@ const context = await firefox.launchPersistentContext(cfg.dir.browser, { 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 locale: "en-US", // ignore OS locale to be sure to have english text for locators - recordVideo: cfg.record ? { dir: 'data/record/', size: { width: cfg.width, height: cfg.height } } : undefined, // will record a .webm video for each page navigated; without size, video would be scaled down to fit 800x800 + recordVideo: cfg.record ? { dir: path.resolve('data/record/'), size: { width: cfg.width, height: cfg.height } } : undefined, // will record a .webm video for each page navigated; without size, video would be scaled down to fit 800x800 recordHar: cfg.record ? { path: `data/record/ue-${datetime()}.har` } : undefined, // will record a HAR file with network requests and responses; can be imported in Chrome devtools handleSIGINT: false, // have to handle ourselves and call context.close(), otherwise recordings from above won't be saved }); From 840d35c2d22bccbc37720c9096d3d773091b30ef Mon Sep 17 00:00:00 2001 From: Ralf Vogler Date: Mon, 18 Sep 2023 13:54:40 +0200 Subject: [PATCH 09/10] =?UTF-8?q?ncu=20-u:=20playwright-firefox=20^1.37.1?= =?UTF-8?q?=20=20=E2=86=92=20=20^1.38.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 3 ++- package-lock.json | 30 +++++++++++++++--------------- package.json | 2 +- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index f686c55..7a291b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -55,9 +55,10 @@ WORKDIR /fgc COPY package*.json ./ # Playwright installs patched firefox to ~/.cache/ms-playwright/firefox-* -# Requires some system deps to run (see install-deps above). +# Requires some system deps to run (see inlined install-deps above). RUN npm install # Old: PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD + install firefox (had to be done after `npm install` to get the correct version). Now: playwright-firefox as npm dep and `npm install` will only install that. +# From 1.38 Playwright will no longer install browser automatically for playwright, but apparently still for playwright-firefox: https://github.com/microsoft/playwright/releases/tag/v1.38.0 # RUN npx playwright install firefox COPY . . diff --git a/package-lock.json b/package-lock.json index b40dc0e..8078e6d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "enquirer": "^2.4.1", "lowdb": "^6.0.1", "otplib": "^12.0.1", - "playwright-firefox": "^1.37.1", + "playwright-firefox": "^1.38.0", "puppeteer-extra-plugin-stealth": "^2.11.2" } }, @@ -448,9 +448,9 @@ } }, "node_modules/playwright-core": { - "version": "1.37.1", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.37.1.tgz", - "integrity": "sha512-17EuQxlSIYCmEMwzMqusJ2ztDgJePjrbttaefgdsiqeLWidjYz9BxXaTaZWxH1J95SHGk6tjE+dwgWILJoUZfA==", + "version": "1.38.0", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.38.0.tgz", + "integrity": "sha512-f8z1y8J9zvmHoEhKgspmCvOExF2XdcxMW8jNRuX4vkQFrzV4MlZ55iwb5QeyiFQgOFCUolXiRHgpjSEnqvO48g==", "bin": { "playwright-core": "cli.js" }, @@ -459,12 +459,12 @@ } }, "node_modules/playwright-firefox": { - "version": "1.37.1", - "resolved": "https://registry.npmjs.org/playwright-firefox/-/playwright-firefox-1.37.1.tgz", - "integrity": "sha512-I8QScyW+hjGltywqLNh3Y1W96/3x70el9wNneuI34l3uVhiCRt9Co27+kiL+UlA1V8MTzaMere3ONQ8lGeut5w==", + "version": "1.38.0", + "resolved": "https://registry.npmjs.org/playwright-firefox/-/playwright-firefox-1.38.0.tgz", + "integrity": "sha512-uNXdvj17JHbKir/EmdLtYEHkzI0ttFMX/3+HO/TW5z1hRmN5CydDNINm9xL/0AwvFSa5unZPM7S7+mUa3EiniA==", "hasInstallScript": true, "dependencies": { - "playwright-core": "1.37.1" + "playwright-core": "1.38.0" }, "bin": { "playwright": "cli.js" @@ -1032,16 +1032,16 @@ "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==" }, "playwright-core": { - "version": "1.37.1", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.37.1.tgz", - "integrity": "sha512-17EuQxlSIYCmEMwzMqusJ2ztDgJePjrbttaefgdsiqeLWidjYz9BxXaTaZWxH1J95SHGk6tjE+dwgWILJoUZfA==" + "version": "1.38.0", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.38.0.tgz", + "integrity": "sha512-f8z1y8J9zvmHoEhKgspmCvOExF2XdcxMW8jNRuX4vkQFrzV4MlZ55iwb5QeyiFQgOFCUolXiRHgpjSEnqvO48g==" }, "playwright-firefox": { - "version": "1.37.1", - "resolved": "https://registry.npmjs.org/playwright-firefox/-/playwright-firefox-1.37.1.tgz", - "integrity": "sha512-I8QScyW+hjGltywqLNh3Y1W96/3x70el9wNneuI34l3uVhiCRt9Co27+kiL+UlA1V8MTzaMere3ONQ8lGeut5w==", + "version": "1.38.0", + "resolved": "https://registry.npmjs.org/playwright-firefox/-/playwright-firefox-1.38.0.tgz", + "integrity": "sha512-uNXdvj17JHbKir/EmdLtYEHkzI0ttFMX/3+HO/TW5z1hRmN5CydDNINm9xL/0AwvFSa5unZPM7S7+mUa3EiniA==", "requires": { - "playwright-core": "1.37.1" + "playwright-core": "1.38.0" } }, "puppeteer-extra-plugin": { diff --git a/package.json b/package.json index 6179433..9a91f7f 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "enquirer": "^2.4.1", "lowdb": "^6.0.1", "otplib": "^12.0.1", - "playwright-firefox": "^1.37.1", + "playwright-firefox": "^1.38.0", "puppeteer-extra-plugin-stealth": "^2.11.2" }, "repository": { From 41f1f9550964563df64e6535b0c2752c944c0c46 Mon Sep 17 00:00:00 2001 From: Ralf Vogler Date: Mon, 18 Sep 2023 14:02:15 +0200 Subject: [PATCH 10/10] PW: replace deprecated type() with pressSequentially() for OTPs --- epic-games.js | 4 ++-- gog.js | 2 +- prime-gaming.js | 2 +- unrealengine.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/epic-games.js b/epic-games.js index 976ce07..16984a3 100644 --- a/epic-games.js +++ b/epic-games.js @@ -99,7 +99,7 @@ try { console.log('Enter the security code to continue - This appears to be a new device, browser or location. A security code has been sent to your email address at ...'); // TODO locator for text (email or app?) const otp = cfg.eg_otpkey && authenticator.generate(cfg.eg_otpkey) || await prompt({type: 'text', message: 'Enter two-factor sign in code', validate: n => n.toString().length == 6 || 'The code must be 6 digits!'}); // can't use type: 'number' since it strips away leading zeros and codes sometimes have them - await page.type('input[name="code-input-0"]', otp.toString()); + await page.locator('input[name="code-input-0"]').pressSequentially(otp.toString()); await page.click('button[type="submit"]'); }).catch(_ => { }); } else { @@ -196,7 +196,7 @@ try { console.error(' EG_PARENTALPIN not set. Need to enter Parental Control PIN manually.'); notify('epic-games: EG_PARENTALPIN not set. Need to enter Parental Control PIN manually.'); } - await iframe.locator('input.payment-pin-code__input').first().type(cfg.eg_parentalpin); + await iframe.locator('input.payment-pin-code__input').first().pressSequentially(cfg.eg_parentalpin); await iframe.locator('button:has-text("Continue")').click({ delay: 11 }); }).catch(_ => { }); diff --git a/gog.js b/gog.js index e41eed7..be4514d 100644 --- a/gog.js +++ b/gog.js @@ -61,7 +61,7 @@ try { console.log('Two-Step Verification - Enter security code'); console.log(await iframe.locator('.form__description').innerText()) const otp = await prompt({type: 'text', message: 'Enter two-factor sign in code', validate: n => n.toString().length == 4 || 'The code must be 4 digits!'}); // can't use type: 'number' since it strips away leading zeros and codes sometimes have them - await iframe.locator('#second_step_authentication_token_letter_1').type(otp.toString(), {delay: 10}); + await iframe.locator('#second_step_authentication_token_letter_1').pressSequentially(otp.toString(), {delay: 10}); await iframe.locator('#second_step_authentication_send').click(); await page.waitForTimeout(1000); // TODO still needed with wait for username below? }).catch(_ => { }); diff --git a/prime-gaming.js b/prime-gaming.js index 3816777..8fcfa2b 100644 --- a/prime-gaming.js +++ b/prime-gaming.js @@ -68,7 +68,7 @@ try { console.log('Two-Step Verification - enter the One Time Password (OTP), e.g. generated by your Authenticator App'); await page.check('[name=rememberDevice]'); const otp = cfg.pg_otpkey && authenticator.generate(cfg.pg_otpkey) || await prompt({type: 'text', message: 'Enter two-factor sign in code', validate: n => n.toString().length == 6 || 'The code must be 6 digits!'}); // can't use type: 'number' since it strips away leading zeros and codes sometimes have them - await page.type('input[name=otpCode]', otp.toString()); + await page.locator('input[name=otpCode]').pressSequentially(otp.toString()); await page.click('input[type="submit"]'); }).catch(_ => { }); } else { diff --git a/unrealengine.js b/unrealengine.js index 55d4e58..f7ee6fa 100644 --- a/unrealengine.js +++ b/unrealengine.js @@ -72,7 +72,7 @@ try { console.log('Enter the security code to continue - This appears to be a new device, browser or location. A security code has been sent to your email address at ...'); // TODO locator for text (email or app?) const otp = cfg.eg_otpkey && authenticator.generate(cfg.eg_otpkey) || await prompt({type: 'text', message: 'Enter two-factor sign in code', validate: n => n.toString().length == 6 || 'The code must be 6 digits!'}); // can't use type: 'number' since it strips away leading zeros and codes sometimes have them - await page.type('input[name="code-input-0"]', otp.toString()); + await page.locator('input[name="code-input-0"]').pressSequentially(otp.toString()); await page.click('button[type="submit"]'); }).catch(_ => { }); } else {