diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index eb9e8a6..c97e5ac 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -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. diff --git a/gog.js b/gog.js index 358e47a..190fd7f 100644 --- a/gog.js +++ b/gog.js @@ -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(); diff --git a/prime-gaming.js b/prime-gaming.js index e5a5984..dfb9d6c 100644 --- a/prime-gaming.js +++ b/prime-gaming.js @@ -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 { diff --git a/src/config.js b/src/config.js index a8b1817..0df7511 100644 --- a/src/config.js +++ b/src/config.js @@ -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