diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index 8c12487..d165560 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -27,11 +27,11 @@ jobs:
-
name: Set environment variables
run: |
- echo "NOW=$(date -R)" >> $GITHUB_ENV # date -Iseconds; date +'%Y-%m-%dT%H:%M:%S'
+ echo "NOW=$(date -R)" >> "$GITHUB_ENV" # date -Iseconds; date +'%Y-%m-%dT%H:%M:%S'
if [[ "$BRANCH" == "main" ]]; then
- echo "IMAGE_TAG=latest" >> $GITHUB_ENV
+ echo "IMAGE_TAG=latest" >> "$GITHUB_ENV"
else
- echo "IMAGE_TAG=$BRANCH" >> $GITHUB_ENV
+ echo "IMAGE_TAG=$BRANCH" >> "$GITHUB_ENV"
fi
-
name: Set up QEMU
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index aaf8218..630ec97 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,6 +1,6 @@
# Contribute
## Building and publishing docker images
-Setup the secrets for DOCKERHUB_USERNAME and [DOCKERHUB_TOKEN](https://hub.docker.com/settings/security) in https://github.com/YOUR_USERNAME/free-games-claimer/settings/secrets/actions to be able to run the docker.yml workflows.
+Setup the secrets for DOCKERHUB_USERNAME and [DOCKERHUB_TOKEN](https://hub.docker.com/settings/security) in `https://github.com/YOUR_USERNAME/free-games-claimer/settings/secrets/actions` to be able to run the docker.yml workflows.
-Check if under Workflow Permissions in https://github.com/YOUR_USERNAME/free-games-claimer/settings/actions the radio button is set to "Read and write permissions". In case that's not set the push to ghcr.io will fail.
\ No newline at end of file
+Check if under Workflow Permissions in `https://github.com/YOUR_USERNAME/free-games-claimer/settings/actions` the radio button is set to "Read and write permissions", otherwise the push to ghcr.io will fail.
diff --git a/Dockerfile b/Dockerfile
index a8c5e24..e2f8006 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -49,7 +49,7 @@ RUN apt-get update \
# RUN npm --version
RUN ln -s /usr/share/novnc/vnc_auto.html /usr/share/novnc/index.html
-RUN pip install apprise
+RUN pip install --no-cache-dir apprise
WORKDIR /fgc
COPY package*.json ./
diff --git a/README.md b/README.md
index 17ec854..e01cb8a 100644
--- a/README.md
+++ b/README.md
@@ -1,15 +1,15 @@
+# free-games-claimer
+[](https://sonarcloud.io/project/overview?id=vogler_free-games-claimer)
+
-[](https://sonarcloud.io/project/overview?id=vogler_free-games-claimer)
-# free-games-claimer
-
Claims free games periodically on
--
[Epic Games Store](https://www.epicgames.com/store/free-games)
--
[Amazon Prime Gaming](https://gaming.amazon.com)
--
[GOG](https://www.gog.com)
--
[Unreal Engine (Assets)](https://www.unrealengine.com/marketplace/en-US/assets?count=20&sortBy=effectiveDate&sortDir=DESC&start=0&tag=4910) ([experimental](https://github.com/vogler/free-games-claimer/issues/44), same login as Epic Games)
+-
[Epic Games Store](https://www.epicgames.com/store/free-games)
+-
[Amazon Prime Gaming](https://gaming.amazon.com)
+-
[GOG](https://www.gog.com)
+-
[Unreal Engine (Assets)](https://www.unrealengine.com/marketplace/en-US/assets?count=20&sortBy=effectiveDate&sortDir=DESC&start=0&tag=4910) ([experimental](https://github.com/vogler/free-games-claimer/issues/44), same login as Epic Games)
Pull requests welcome :)
@@ -22,7 +22,7 @@ Raspberry Pi (3, 4, Zero 2): [requires 64-bit OS](https://github.com/vogler/free
## How to run
Easy option: [install Docker](https://docs.docker.com/get-docker/) (or [podman](https://podman-desktop.io/)) and run this command in a terminal:
-```
+```sh
docker run --rm -it -p 6080:6080 -v fgc:/fgc/data --pull=always ghcr.io/vogler/free-games-claimer
```
@@ -48,7 +48,7 @@ If you don't want to use Docker for quasi-headless mode, you could run inside a
## Usage
-All scripts start an automated Firefox instance, either with the browser GUI shown or hidden (*headless mode*). By default, you won't see any browser open on your host system.
+All scripts start an automated Firefox instance, either with the browser GUI shown or hidden (_headless mode_). By default, you won't see any browser open on your host system.
- When running inside Docker, the browser will be shown only inside the container. You can open http://localhost:6080 to interact with the browser running inside the container via noVNC (or use other VNC clients on port 5900).
- When running the scripts outside of Docker, the browser will be hidden by default; you can use `SHOW=1 ...` to show the UI (see options below).
@@ -67,32 +67,32 @@ TODO: ~~On the first run, the script will guide you through configuration and sa
Available options/variables and their default values:
-| Option | Default | Description |
-|--------------- |--------- |------------------------------------------------------------------------ |
-| SHOW | 1 | Show browser if 1. Default for Docker, not shown when running outside. |
-| WIDTH | 1280 | Width of the opened browser (and of screen for VNC in Docker). |
-| HEIGHT | 1280 | Height of the opened browser (and of screen for VNC in Docker). |
-| VNC_PASSWORD | | VNC password for Docker. No password used by default! |
-| NOTIFY | | Notification services to use (Pushover, Slack, Telegram...), see below. [Apprise](https://github.com/caronc/apprise) |
-| NOTIFY_TITLE | | Optional title for notifications, e.g. for Pushover. |
-| BROWSER_DIR | data/browser | Directory for browser profile, e.g. for multiple accounts. |
-| TIMEOUT | 60 | Timeout for any page action. Should be fine even on slow machines. |
-| LOGIN_TIMEOUT | 180 | Timeout for login in seconds. Will wait twice (prompt + manual login). |
-| EMAIL | | Default email for any login. |
-| PASSWORD | | Default password for any login. |
-| EG_EMAIL | | Epic Games email for login. Overrides EMAIL. |
-| EG_PASSWORD | | Epic Games password for login. Overrides PASSWORD. |
-| EG_OTPKEY | | Epic Games MFA OTP key. |
-| EG_PARENTALPIN | | Epic Games Parental Controls PIN. |
-| PG_EMAIL | | Prime Gaming email for login. Overrides EMAIL. |
-| PG_PASSWORD | | Prime Gaming password for login. Overrides PASSWORD. |
-| PG_OTPKEY | | Prime Gaming MFA OTP key. |
-| PG_REDEEM | 0 | Prime Gaming: try to redeem keys on external stores ([experimental](https://github.com/vogler/free-games-claimer/issues/5)). |
-| PG_CLAIMDLC | 0 | Prime Gaming: try to claim DLCs ([experimental](https://github.com/vogler/free-games-claimer/issues/55)). |
-| GOG_EMAIL | | GOG email for login. Overrides EMAIL. |
-| GOG_PASSWORD | | GOG password for login. Overrides PASSWORD. |
-| GOG_NEWSLETTER | 0 | Do not unsubscribe from newsletter after claiming a game if 1. |
-| LG_EMAIL | | Legacy Games: email to use for redeeming (if not set, defaults to PG_EMAIL) |
+| Option | Default | Description |
+|-----------------|--------------|------------------------------------------------------------------------------|
+| SHOW | 1 | Show browser if 1. Default for Docker, not shown when running outside. |
+| WIDTH | 1280 | Width of the opened browser (and of screen for VNC in Docker). |
+| HEIGHT | 1280 | Height of the opened browser (and of screen for VNC in Docker). |
+| VNC_PASSWORD | | VNC password for Docker. No password used by default! |
+| NOTIFY | | Notification services to use (Pushover, Slack, Telegram...), see below. |
+| NOTIFY_TITLE | | Optional title for notifications, e.g. for Pushover. |
+| BROWSER_DIR | data/browser | Directory for browser profile, e.g. for multiple accounts. |
+| TIMEOUT | 60 | Timeout for any page action. Should be fine even on slow machines. |
+| LOGIN_TIMEOUT | 180 | Timeout for login in seconds. Will wait twice (prompt + manual login). |
+| EMAIL | | Default email for any login. |
+| PASSWORD | | Default password for any login. |
+| EG_EMAIL | | Epic Games email for login. Overrides EMAIL. |
+| EG_PASSWORD | | Epic Games password for login. Overrides PASSWORD. |
+| EG_OTPKEY | | Epic Games MFA OTP key. |
+| EG_PARENTALPIN | | Epic Games Parental Controls PIN. |
+| PG_EMAIL | | Prime Gaming email for login. Overrides EMAIL. |
+| PG_PASSWORD | | Prime Gaming password for login. Overrides PASSWORD. |
+| PG_OTPKEY | | Prime Gaming MFA OTP key. |
+| PG_REDEEM | 0 | Prime Gaming: try to redeem keys on external stores ([experimental](https://github.com/vogler/free-games-claimer/issues/5)). |
+| PG_CLAIMDLC | 0 | Prime Gaming: try to claim DLCs ([experimental](https://github.com/vogler/free-games-claimer/issues/55)). |
+| GOG_EMAIL | | GOG email for login. Overrides EMAIL. |
+| GOG_PASSWORD | | GOG password for login. Overrides PASSWORD. |
+| GOG_NEWSLETTER | 0 | Do not unsubscribe from newsletter after claiming a game if 1. |
+| LG_EMAIL | | Legacy Games: email to use for redeeming (if not set, defaults to PG_EMAIL). |
See `src/config.js` for all options.
@@ -100,7 +100,10 @@ See `src/config.js` for all options.
You can add options directly in the command or put them in a file to load.
##### Docker
-You can pass variables using `-e VAR=VAL`, for example `docker run -e EMAIL=foo@bar.baz -e NOTIFY='tgram://bottoken/ChatID' ...` or using `--env-file fgc.env` where `fgc.env` is a file on your host system (see [docs](https://docs.docker.com/engine/reference/commandline/run/#env)). You can also `docker cp` your configuration file to `/fgc/data/config.env` in the `fgc` volume to store it with the rest of the data instead of on the host ([example](https://github.com/moby/moby/issues/25245#issuecomment-365980572)).
+You can pass variables using `-e VAR=VAL`.
+For example, `docker run -e EMAIL=foo@bar.baz -e NOTIFY='tgram://bottoken/ChatID' ...`.
+Alternatively, you can pass a file with `--env-file fgc.env` where `fgc.env` is a file on your host system (see [docs](https://docs.docker.com/engine/reference/commandline/run/#env)).
+You can also `docker cp` your configuration file to `/fgc/data/config.env` in the `fgc` volume to store it with the rest of the data instead of on the host ([example](https://github.com/moby/moby/issues/25245#issuecomment-365980572)).
If you are using [docker compose](https://docs.docker.com/compose/environment-variables/) (or Portainer etc.), you can put options in the `environment:` section.
##### Without Docker
@@ -143,10 +146,10 @@ Claiming the Amazon Games works out-of-the-box, however, for games on external s
### Run periodically
#### How often?
-Epic Games usually has two free games *every week*, before Christmas every day.
-Prime Gaming has new games *every month* or more often during Prime days.
+Epic Games usually has two free games _every week_, before Christmas every day.
+Prime Gaming has new games _every month_ or more often during Prime days.
GOG usually has one new game every couples of weeks.
-Unreal Engine has new assets to claim *every first Tuesday of a month*.
+Unreal Engine has new assets to claim _every first Tuesday of a month_.
It is safe to run the scripts every day.
@@ -176,10 +179,10 @@ If you're a developer, you can use `PWDEBUG=1 ...` to [inspect](https://playwrig
Tried [epicgames-freebies-claimer](https://github.com/Revadike/epicgames-freebies-claimer), but had problems since epicgames introduced hcaptcha (see [issue](https://github.com/Revadike/epicgames-freebies-claimer/issues/172)).
-Played around with puppeteer before, now trying newer https://playwright.dev which is pretty similar.
+Played around with Puppeteer before, now trying newer [Playwright](https://playwright.dev) which is pretty similar.
Playwright Inspector and `codegen` to generate scripts are nice, but failed to generate the right code for clicking a button in an iframe.
-Added [main.spec.ts](https://github.com/vogler/epicgames-claimer/commit/e5ce7916ab6329cfc7134677c4d89c2b3fa3ba97#diff-d18d03e9c407a20e05fbf03cbd6f9299857740544fb6b50d6a70b9c6fbc35831) which was the test script generated by `npx playwright codegen` with manual fix for clicking buttons in the created iframe. Can be executed by `npx playwright test`. The test runner has options `--debug` and `--timeout` and can execute typescript which is nice. However, this only worked up to the button 'I Agree', and then showed an hcaptcha.
+Added [main.spec.ts](https://github.com/vogler/epicgames-claimer/commit/e5ce7916ab6329cfc7134677c4d89c2b3fa3ba97#diff-d18d03e9c407a20e05fbf03cbd6f9299857740544fb6b50d6a70b9c6fbc35831) which was the test script generated by `npx playwright codegen` with manual fix for clicking buttons in the created iframe. Can be executed by `npx playwright test`. The test runner has options `--debug` and `--timeout` and can execute TypeScript which is nice. However, this only worked up to the button 'I Agree', and then showed an hcaptcha.
Added [main.captcha.js](https://github.com/vogler/epicgames-claimer/commit/e5ce7916ab6329cfc7134677c4d89c2b3fa3ba97#diff-d18d03e9c407a20e05fbf03cbd6f9299857740544fb6b50d6a70b9c6fbc35831) which uses beta of `playwright-extra@next` and `@extra/recaptcha@next` (from [comment on puppeteer-extra](https://github.com/berstend/puppeteer-extra/pull/303#issuecomment-775277480)).
However, `playwright-extra` seems to be old and missing `:has-text` selector (fixed [here](https://github.com/vogler/epicgames-claimer/commit/ba97a0e840b65f4476cca18e28d8461b0c703420)) and `page.frameLocator`, so the script did not run without adjustments.
@@ -199,7 +202,7 @@ Renamed repository from epicgames-claimer to free-games-claimer since a script f
epic games: `headless` mode gets hcaptcha challenge. More details/references in [issue](https://github.com/vogler/free-games-claimer/issues/2).
-https://github.com/vogler/free-games-claimer/pull/11 introduced a Dockerfile for running non-headless inside the container via xvfb which makes it headless for the host running the container.
+[PR](https://github.com/vogler/free-games-claimer/pull/11) introduced a Dockerfile for running non-headless inside the container via xvfb which makes it headless for the host running the container.
v1.0 Standalone scripts node epic-games and node prime-gaming using Chromium.
diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh
index 5837164..7aa8772 100755
--- a/docker-entrypoint.sh
+++ b/docker-entrypoint.sh
@@ -3,7 +3,7 @@
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}"
+[ -n "$BRANCH" ] && [ "$BRANCH" != "main" ] && echo "Branch: ${BRANCH}"
echo "Build: $NOW"
# Remove chromium profile lock.
@@ -17,7 +17,7 @@ rm -f /fgc/data/browser/SingletonLock
mkdir -p /fgc/data/browser
# fix for 'Incorrect response' after solving a captcha correctly - https://github.com/vogler/free-games-claimer/issues/261#issuecomment-1868385830
# echo 'user_pref("privacy.resistFingerprinting", true);' > /fgc/data/browser/user.js
-cat << EOT > /fgc/data/browser/user.js
+cat << EOT >/fgc/data/browser/user.js
user_pref("privacy.resistFingerprinting", true);
// user_pref("privacy.resistFingerprinting.letterboxing", true);
// user_pref("browser.contentblocking.category", "strict");
@@ -47,9 +47,9 @@ else
pw="-passwd $VNC_PASSWORD"
pwt="with password"
fi
-x11vnc -display $DISPLAY -forever -shared -rfbport $VNC_PORT -bg $pw 2>/dev/null 1>&2
+x11vnc -display $DISPLAY -forever -shared -rfbport "$VNC_PORT" -bg "$pw" 2>/dev/null 1>&2
echo "VNC is running on port $VNC_PORT ($pwt)"
-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 &
echo "noVNC (VNC via browser) is running on http://localhost:$NOVNC_PORT"
echo
exec tini -g -- "$@" # https://github.com/krallin/tini/issues/8 node/playwright respond to signals like ctrl-c, but unsure about zombie processes