mirror of
https://github.com/User0332/rewards-farmer.git
synced 2026-09-16 01:31:36 +00:00
run in docker, and work through more than one account
Both taken from TheNetsky/Microsoft-Rewards-Script, which packages a container and handles several accounts. Approach only: that project is GPL-3.0 and this one MIT, so no code crosses over. **Accounts.** Rewards is per Microsoft account and the browser profile holds the sign-in, so an account here is a profile directory. REWARDS_ACCOUNTS takes a comma separated list and gives each its own directory under the configured one. They run in sequence, and a profile that will not start is reported and skipped rather than ending the run. Left unset, a run uses the single profile exactly as before. Names are validated rather than trusted: they become directory names, so "../escape" is refused instead of quietly writing outside data-dir. **Docker.** The image carries only what main.py actually reaches, selenium and numpy. pygetwindow, keyboard, matplotlib and pygame are used solely by the recording and visualisation scripts, and two of those are Windows-only, so none of them belong in a container. msedgedriver is pinned at build time to the Edge the image installed rather than to latest, which drifts from it between releases. QUERY_SOURCE defaults to trends in the image, so a container needs no Ollama account and no model download at all. That default turned out to require a fix. queries.py imported llm_utils at module scope, which imports ollama, so a trends-only install still needed the ollama package: exactly what running in a minimal image is good at exposing. The import is now made inside the llm branch, and the wordlist fallback reads nouns.txt directly rather than borrowing llm_utils.get_random_noun. REWARDS_HEADLESS drives the headless flags. The window size is set explicitly because the pointer code works in viewport coordinates and the default headless window is small enough to put cards out of reach, which is the MoveTargetOutOfBoundsException from #19. Verified on the host that move_to_element and human_like_click both work headless before relying on it. Verified in the built image: Edge 151.0.4129.107 with a driver of exactly the same build, the trends feed reachable from inside, Edge driven to bing.com and rewards.bing.com at 1920x1080, and REWARDS_ACCOUNTS producing separate profile directories with traversal refused.
This commit is contained in:
@@ -66,4 +66,47 @@ EU Users: you may have to accept a consent banner once on `rewards.bing.com` and
|
||||
|
||||
Close all webdriver browser instances. Run `main.py` again; the automation should start working.
|
||||
|
||||
# Running more than one account
|
||||
|
||||
Rewards is per Microsoft account and the browser profile holds the sign-in, so an account here is a profile directory. `REWARDS_ACCOUNTS` takes a comma separated list, and each name gets its own directory under `data-dir`:
|
||||
|
||||
```sh
|
||||
REWARDS_ACCOUNTS=personal,spare python src/main.py
|
||||
```
|
||||
|
||||
Each is signed in once by hand, the same way as the single profile, using its own directory:
|
||||
|
||||
```
|
||||
msedge --user-data-dir="<repo>\data-dir\personal" --profile-directory=Default https://rewards.bing.com
|
||||
```
|
||||
|
||||
They run one after another, and a profile that fails to start is reported and skipped rather than ending the run. Leave `REWARDS_ACCOUNTS` unset and everything behaves exactly as before, using the single profile in `data-dir`.
|
||||
|
||||
# Docker
|
||||
|
||||
Runs the bot without installing Edge, a driver or Python on the host.
|
||||
|
||||
```sh
|
||||
docker compose build
|
||||
docker compose run --rm rewards-farmer
|
||||
```
|
||||
|
||||
The container defaults to `QUERY_SOURCE=trends`, so it needs no Ollama account and no model. Set `QUERY_SOURCE=llm` and `OLLAMA_HOST` to a reachable address to use a model instead.
|
||||
|
||||
**Sign in first.** The profile in `data-dir` starts logged out and the container has no display to sign in with, so do it once on the host with a normal Edge window and let the volume carry it in:
|
||||
|
||||
```
|
||||
msedge --user-data-dir="<repo>\data-dir" --profile-directory=Default https://rewards.bing.com
|
||||
```
|
||||
|
||||
Close every window of that profile afterwards. Chromium allows one process per profile directory, so a window left open on the host stops the container from starting.
|
||||
|
||||
Multiple accounts work the same way in the container:
|
||||
|
||||
```sh
|
||||
REWARDS_ACCOUNTS=personal,spare docker compose run --rm rewards-farmer
|
||||
```
|
||||
|
||||
`REWARDS_HEADLESS=1` is set in the image. It also works on the host if you want a run with no visible window; the pointer code needs an explicit window size in that mode, which `main.py` sets.
|
||||
|
||||
Please open up a GitHub issue if you run into any difficulties.
|
||||
Reference in New Issue
Block a user