chore: make version banner configurable and speed up login waits
All checks were successful
build-and-push / lint (push) Successful in 4s
build-and-push / sonar (push) Successful in 12s
build-and-push / docker (push) Successful in 1m10s

This commit is contained in:
nocci 2025-12-31 11:58:35 +00:00
parent 34e8d92b05
commit 133502ff94
4 changed files with 13 additions and 4 deletions

View file

@ -2,8 +2,13 @@
set -eo pipefail # exit on error, error on any fail in pipe (not just last cmd); add -x to print each cmd; see gist bash_strict_mode.md
echo "Version: https://github.com/vogler/free-games-claimer/tree/${COMMIT}"
[ ! -z $BRANCH ] && [ $BRANCH != "main" ] && echo "Branch: ${BRANCH}"
REPO_URL=${REPO_URL:-https://git.sky-net.it/nocci/free-games-claimer}
if [ -n "$COMMIT" ]; then
echo "Version: ${REPO_URL}/tree/${COMMIT}"
else
echo "Version: ${REPO_URL}"
fi
[ -n "$BRANCH" ] && [ "$BRANCH" != "main" ] && echo "Branch: ${BRANCH}"
echo "Build: $NOW"
# Ensure writable data dir for fgc when host bind-mount is owned by root.

5
gog.js
View file

@ -42,7 +42,10 @@ try {
await page.goto(URL_CLAIM, { waitUntil: 'domcontentloaded' }); // default 'load' takes forever
const signIn = page.locator('a:has-text("Sign in")').first();
await Promise.any([signIn.waitFor(), page.waitForSelector('#menuUsername')]);
await Promise.any([
signIn.waitFor({ timeout: cfg.login_visible_timeout }),
page.waitForSelector('#menuUsername', { timeout: cfg.login_visible_timeout }),
]).catch(() => {});
while (await signIn.isVisible()) {
console.error('Not signed in anymore.');
await signIn.click();

View file

@ -111,7 +111,7 @@ try {
'button:has-text("Anmelden")',
'[data-a-target="user-dropdown-first-name-text"]',
'[data-testid="user-dropdown-first-name-text"]',
].map(s => page.waitForSelector(s)));
].map(s => page.waitForSelector(s, { timeout: cfg.login_visible_timeout }))).catch(() => {});
try {
await page.click('[aria-label="Cookies usage disclaimer banner"] button:has-text("Accept Cookies")'); // to not waste screen space when non-headless; could be flaky
} catch {

View file

@ -19,6 +19,7 @@ export const cfg = {
height: Number(process.env.HEIGHT) || 1080, // height of the opened browser
timeout: (Number(process.env.TIMEOUT) || 60) * 1000, // default timeout for playwright is 30s
login_timeout: (Number(process.env.LOGIN_TIMEOUT) || 180) * 1000, // higher timeout for login, will wait twice: prompt + wait for manual login
login_visible_timeout: (Number(process.env.LOGIN_VISIBLE_TIMEOUT) || 20) * 1000, // how long to wait for login button/user indicator to appear
novnc_port: process.env.NOVNC_PORT, // running in docker if set
notify: process.env.NOTIFY, // apprise notification services
notify_title: process.env.NOTIFY_TITLE, // apprise notification title