5 Commits

Author SHA1 Message Date
TheNetsky
ef6ad569ff 1.4.6 2024-05-09 10:04:11 +02:00
Netsky
da9ba91c5c Merge pull request #98 from jordyamc/main
Bug when detecting earnable points from more promotions
2024-05-07 15:12:10 +02:00
Jordy Mendoza
deb2d58b1b - Fix bug where the script was using x.activityType instead of x.promotionType this was causing that the script wasn't detecting earnable points from more promotions 2024-04-21 23:50:33 -06:00
Netsky
66a82c2584 Merge pull request #89 from mgrimace/docker
Clarify docker instructions, add basic compose.yaml support
2024-04-04 16:43:57 +02:00
mgrimace
8a022d5983 Clarify docker instructions, add basic compose.yaml support
This should help folks get started with docker and hopefully make it easier for testing
2024-04-03 17:59:16 -04:00
9 changed files with 43 additions and 9 deletions

3
.gitignore vendored
View File

@@ -5,4 +5,5 @@ package-lock.json
accounts.json
notes
accounts.dev.json
accounts.main.json
accounts.main.json
.DS_Store

View File

@@ -17,9 +17,26 @@ Under development, however mainly for personal use!
## Docker (Experimental) ##
1. Download the source code
2. Make changes to your `accounts.json` and/or `config.json`
3. Run `docker build -t microsoft-rewards-script-docker .`
- Docker container has to be recreated for any changes regarding the `config.json` and/or `accounts.json`!
2. Make changes to your `accounts.json`
3. Make sure to change `"headless": false` to `"headless": true` in your `config.json`
4. Note, the container has to be recreated for any changes regarding the `config.json` and/or `accounts.json`!
### Option 1: build and run with docker run
1. Run `docker build -t microsoft-rewards-script-docker .` to build the container
2. Run the container with `docker run --name netsky -d microsoft-rewards-script-docker` or, omit the detached flag `-d` to view the script output in your terminal.
3. Optionally, change the name of the container by changing `--name netsky` to your preferred container name
4. The container will exit after completing the script, run it again using `docker start netsky`
5. If you are running the container `-d` detached, you can view logs with `docker logs netsky`
### Option 2: use docker compose
1. A basic docker compose.yaml has been provided, which can be run with `docker compose up -d` or, omit the detached flag `-d` to view the script output in your terminal.
2. The container will exit after completing the script, run it again using `docker start netsky`
3. If you are running the container `-d` detached, you can view logs with `docker logs netsky`
## Config ##
| Setting | Description | Default |
@@ -35,6 +52,7 @@ Under development, however mainly for personal use!
| workers.doPunchCards | Complete punchcards | `true` |
| workers.doDesktopSearch | Complete daily desktop searches | `true` |
| workers.doMobileSearch | Complete daily mobile searches | `true` |
| globalTimeout | The length before the action gets timeout | 30 seconds (30.000 miliseconds) |
| searchSettings.useGeoLocaleQueries | Generate search queries based on your geo-location | `false` (Uses EN-US generated queries) |
| scrollRandomResults | Scroll randomly in search results | `true` |
| searchSettings.clickRandomResults | Visit random website from search result| `true` |

8
compose.yaml Normal file
View File

@@ -0,0 +1,8 @@
services:
microsoft-rewards-script:
build: .
container_name: netsky
environment:
- NODE_ENV=production
volumes:
- .:/usr/src/microsoft-rewards-script

View File

@@ -1,6 +1,6 @@
{
"name": "microsoft-rewards-script",
"version": "1.4.5",
"version": "1.4.6",
"description": "Automatically do tasks for Microsoft Rewards but in TS!",
"main": "index.js",
"engines": {

View File

@@ -43,6 +43,9 @@ class Browser {
const context = await newInjectedContext(browser, { fingerprint: fingerpint })
// Set timeout to preferred amount
context.setDefaultTimeout(this.bot.config?.globalTimeout ?? 30_000)
await context.addCookies(sessionData.cookies)
if (this.bot.config.saveFingerprint) {

View File

@@ -158,7 +158,7 @@ export default class BrowserFunc {
if (data.morePromotions?.length) {
data.morePromotions.forEach(x => {
// Only count points from supported activities
if (['quiz', 'urlreward'].includes(x.activityType)) {
if (['quiz', 'urlreward'].includes(x.promotionType)) {
totalEarnablePoints += (x.pointProgressMax - x.pointProgress)
}
})

View File

@@ -12,6 +12,7 @@
"doDesktopSearch": true,
"doMobileSearch": true
},
"globalTimeout": 30000,
"searchSettings": {
"useGeoLocaleQueries": false,
"scrollRandomResults": true,
@@ -26,4 +27,4 @@
"enabled": false,
"url": ""
}
}
}

View File

@@ -181,7 +181,8 @@ export class MicrosoftRewardsBot {
await saveSessionData(this.config.sessionPath, browser, account.email, this.isMobile)
// Close desktop browser
return await this.closeBrowser(browser, account.email)
await this.closeBrowser(browser, account.email)
return
}
// Mobile
@@ -241,7 +242,8 @@ export class MicrosoftRewardsBot {
log('MAIN-POINTS', `The script collected ${this.collectedPoints} points today`)
// Close mobile browser
return await this.closeBrowser(browser, account.email)
await this.closeBrowser(browser, account.email)
return
}
private async closeBrowser(browser: BrowserContext, email: string) {

View File

@@ -5,6 +5,7 @@ export interface Config {
runOnZeroPoints: boolean;
clusters: number;
workers: Workers;
globalTimeout: number;
searchSettings: SearchSettings;
webhook: Webhook;
saveFingerprint: boolean;