Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release npm package #219

Open
vogler opened this issue Sep 22, 2023 · 4 comments
Open

Release npm package #219

vogler opened this issue Sep 22, 2023 · 4 comments
Labels
feature New feature or request

Comments

@vogler
Copy link
Owner

vogler commented Sep 22, 2023

To have a lightweight alternative to the Docker image (currently shows captcha),
it would be good to be able to do npx free-games-claimer.

People than just have to install Node.js/npm instead of Docker.
Notifications would still require pip install apprise. Maybe there's some similar npm package one could use.

@vogler vogler added the feature New feature or request label Sep 22, 2023
@ladiko
Copy link

ladiko commented Nov 11, 2023

On Windows I just installed git and nodejs, cloned the repository and added a cmd-script which will handle everything else automatically like downloading and/or updating the browser, updating the repository and so on;

cd /d "%~dp0"

REM uncomment next line if you want to use browser window login
REM set SHOW=1

@REM if script is called with "log" as argument / parameter,
@REM restart with logging to file f.e. for Windows Task Scheduler
if "%~1" == "log" (
	"%~f0" nil > "%~dp0\free-games-claimer.log" 2>&1
	exit
)

git reset -q --hard
git pull -q

@REM by default all browsers (chromium, firefox, webkit) are downloaded
@REM disable browser download during npm update/install
set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
cmd /c npm update --silent

@REM by default browsers are downloaded to %LOCALAPPDATA%\pw-browsers
@REM set browser download location to a path inside the free-games-claimer directory
set PLAYWRIGHT_BROWSERS_PATH=%~dp0\pw-browsers
cmd /c npx --quiet playwright install firefox

node epic-games
node unrealengine
node gog
node prime-gaming

@REM cleanup firefox cache
rmdir /s /q "%LOCALAPPDATA%\ms-playwright" "%~dp0\data\screenshots\" "%~dp0\data\browser\cache2" "%~dp0\data\browser\startupCache" "%~dp0\data\browser\storage"
del /f "%~dp0\data\browser\favicons.sqlite" "%~dp0\data\browser\places.sqlite"

if "%~1" == "" pause

So if its's double clicked, the repository gets updated and you see the progress inside a command line window, if called by task scheduler with logas argument, the output gets logged to the file free-games-claimer.log to check later if calling it by task scheduler works, The folder has a size of 241 MB mostly cause of firefox (plus nodejs and git).

@vogler
Copy link
Owner Author

vogler commented Nov 16, 2023

Any reason you delete the cache? Just to save space or did it help with something?

@ladiko
Copy link

ladiko commented Dec 3, 2023

No real reason to delete the cache, The reason to use the cmd version instead of the docker image is to save space. I would even prefer to use the globally installed firefox or the much smaller webkit browser instead of 200megs for an extra firefox, but yeah that's just my paranoid way of using as less space as possible.

As your initial issue topic is about an npm package, it means it would have to be JavaScript? I think the cmd-file is quite okay for Windows users to adapt and if someon adds an equivalent sh-file for Linux it would be a quite minimalistic solutions for interested users?

@vogler
Copy link
Owner Author

vogler commented Dec 18, 2023

You can use your global Firefox by setting executablePath in launchPersistentContext. Probably not worth the trouble though (may break on version change, safety...).
https://playwright.dev/docs/browsers#managing-browser-binaries - doesn't look like webkit is much smaller (maybe the docs are outdated though):

$ du -hs ~/Library/Caches/ms-playwright/*
281M  chromium-XXXXXX
187M  firefox-XXXX
180M  webkit-XXXX

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants