mirror of
https://github.com/TheNetsky/Microsoft-Rewards-Script.git
synced 2026-01-17 21:43:59 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2fea17c415 | ||
|
|
c5beccb54b | ||
|
|
b566ccaece |
11
README.md
11
README.md
@@ -14,14 +14,19 @@ Under development, however mainly for personal use!
|
|||||||
## Notes ##
|
## Notes ##
|
||||||
- If you end the script without closing the browser window first (only with headless as false), you'll be left with hanging chrome instances using resources. Use taskmanager to kill these or use the included `npm run chrome-kill-win` script. (Windows)
|
- If you end the script without closing the browser window first (only with headless as false), you'll be left with hanging chrome instances using resources. Use taskmanager to kill these or use the included `npm run chrome-kill-win` script. (Windows)
|
||||||
- If you automate this script, set it to run at least 2 times a day to make sure it picked up all tasks, set `"runOnZeroPoints": false` so it doesn't run when no points are found.
|
- If you automate this script, set it to run at least 2 times a day to make sure it picked up all tasks, set `"runOnZeroPoints": false` so it doesn't run when no points are found.
|
||||||
- Docker container has to be recreated for any changes regardings the `config.json` and/or `accounts.json`.
|
|
||||||
|
## 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`!
|
||||||
|
|
||||||
## Config ##
|
## Config ##
|
||||||
| Setting | Description | Default |
|
| Setting | Description | Default |
|
||||||
| :------------- |:-------------| :-----|
|
| :------------- |:-------------| :-----|
|
||||||
| baseURL | MS Rewards page | `https://rewards.bing.com` |
|
| baseURL | MS Rewards page | `https://rewards.bing.com` |
|
||||||
| sessionPath | Path to where you want sessions/fingerprints to be stored | `sessions` (In src/browser/sessions) |
|
| sessionPath | Path to where you want sessions/fingerprints to be stored | `sessions` (In ./browser/sessions) |
|
||||||
| headless | If the browser window should be visable be ran in the background | `false` (Browser is visable) |
|
| headless | If the browser window should be visible be ran in the background | `false` (Browser is visible) |
|
||||||
| runOnZeroPoints | Run the rest of the script if 0 points can be earned | `false` (Will not run on 0 points) |
|
| runOnZeroPoints | Run the rest of the script if 0 points can be earned | `false` (Will not run on 0 points) |
|
||||||
| clusters | Amount of instances ran on launch, 1 per account | `1` (Will run 1 account at the time) |
|
| clusters | Amount of instances ran on launch, 1 per account | `1` (Will run 1 account at the time) |
|
||||||
| saveFingerprint | Re-use the same fingerprint each time | `false` (Will generate a new fingerprint each time) |
|
| saveFingerprint | Re-use the same fingerprint each time | `false` (Will generate a new fingerprint each time) |
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "microsoft-rewards-script",
|
"name": "microsoft-rewards-script",
|
||||||
"version": "1.4.1",
|
"version": "1.4.3",
|
||||||
"description": "Automatically do tasks for Microsoft Rewards but in TS!",
|
"description": "Automatically do tasks for Microsoft Rewards but in TS!",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
"ts-start": "ts-node ./src/index.ts",
|
"ts-start": "ts-node ./src/index.ts",
|
||||||
"dev": "ts-node ./src/index.ts -dev",
|
"dev": "ts-node ./src/index.ts -dev",
|
||||||
"kill-chrome-win": "powershell -Command \"Get-Process | Where-Object { $_.MainModule.FileVersionInfo.FileDescription -eq 'Google Chrome for Testing' } | ForEach-Object { Stop-Process -Id $_.Id -Force }\"",
|
"kill-chrome-win": "powershell -Command \"Get-Process | Where-Object { $_.MainModule.FileVersionInfo.FileDescription -eq 'Google Chrome for Testing' } | ForEach-Object { Stop-Process -Id $_.Id -Force }\"",
|
||||||
"create-docker" : "docker build -t microsoft-rewards-script-docker ."
|
"create-docker": "docker build -t microsoft-rewards-script-docker ."
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"Bing Rewards",
|
"Bing Rewards",
|
||||||
@@ -32,11 +32,11 @@
|
|||||||
"typescript": "^5.3.3"
|
"typescript": "^5.3.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.6.2",
|
"axios": "^1.6.5",
|
||||||
"cheerio": "^1.0.0-rc.12",
|
"cheerio": "^1.0.0-rc.12",
|
||||||
"fingerprint-generator": "^2.1.46",
|
"fingerprint-generator": "^2.1.46",
|
||||||
"fingerprint-injector": "^2.1.46",
|
"fingerprint-injector": "^2.1.46",
|
||||||
"playwright": "^1.40.1",
|
"playwright": "^1.41.1",
|
||||||
"ts-node": "^10.9.2"
|
"ts-node": "^10.9.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export class Workers {
|
|||||||
// Punch Card
|
// Punch Card
|
||||||
async doPunchCard(page: Page, data: DashboardData) {
|
async doPunchCard(page: Page, data: DashboardData) {
|
||||||
|
|
||||||
const punchCardsUncompleted = data.punchCards?.filter(x => !x.parentPromotion.complete) ?? [] // Only return uncompleted punch cards
|
const punchCardsUncompleted = data.punchCards?.filter(x => !x.parentPromotion?.complete) ?? [] // Only return uncompleted punch cards
|
||||||
|
|
||||||
if (!punchCardsUncompleted.length) {
|
if (!punchCardsUncompleted.length) {
|
||||||
this.bot.log('PUNCH-CARD', 'All "Punch Cards" have already been completed')
|
this.bot.log('PUNCH-CARD', 'All "Punch Cards" have already been completed')
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Page } from 'playwright'
|
import { Page } from 'playwright'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
import { platform } from 'os'
|
||||||
|
|
||||||
import { Workers } from '../Workers'
|
import { Workers } from '../Workers'
|
||||||
|
|
||||||
@@ -128,17 +129,25 @@ export class Search extends Workers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async bingSearch(searchPage: Page, query: string) {
|
private async bingSearch(searchPage: Page, query: string) {
|
||||||
|
const platformControlKey = platform() === 'darwin' ? 'Meta' : 'Control'
|
||||||
|
|
||||||
// Try a max of 5 times
|
// Try a max of 5 times
|
||||||
for (let i = 0; i < 5; i++) {
|
for (let i = 0; i < 5; i++) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
// Go to top of the page
|
||||||
|
await searchPage.evaluate(() => {
|
||||||
|
window.scrollTo(0, 0)
|
||||||
|
})
|
||||||
|
|
||||||
const searchBar = '#sb_form_q'
|
const searchBar = '#sb_form_q'
|
||||||
await searchPage.waitForSelector(searchBar, { state: 'attached', timeout: 10_000 })
|
await searchPage.waitForSelector(searchBar, { state: 'visible', timeout: 10_000 })
|
||||||
await searchPage.click(searchBar) // Focus on the textarea
|
await searchPage.click(searchBar) // Focus on the textarea
|
||||||
await this.bot.utils.wait(500)
|
await this.bot.utils.wait(500)
|
||||||
await searchPage.keyboard.down('Control')
|
await searchPage.keyboard.down(platformControlKey)
|
||||||
await searchPage.keyboard.press('A')
|
await searchPage.keyboard.press('A')
|
||||||
await searchPage.keyboard.press('Backspace')
|
await searchPage.keyboard.press('Backspace')
|
||||||
await searchPage.keyboard.up('Control')
|
await searchPage.keyboard.up(platformControlKey)
|
||||||
await searchPage.keyboard.type(query)
|
await searchPage.keyboard.type(query)
|
||||||
await searchPage.keyboard.press('Enter')
|
await searchPage.keyboard.press('Enter')
|
||||||
|
|
||||||
@@ -152,6 +161,7 @@ export class Search extends Workers {
|
|||||||
await this.clickRandomLink(searchPage)
|
await this.clickRandomLink(searchPage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delay between searches
|
||||||
await this.bot.utils.wait(Math.floor(this.bot.utils.randomNumber(this.bot.config.searchSettings.searchDelay.min, this.bot.config.searchSettings.searchDelay.max)))
|
await this.bot.utils.wait(Math.floor(this.bot.utils.randomNumber(this.bot.config.searchSettings.searchDelay.min, this.bot.config.searchSettings.searchDelay.max)))
|
||||||
|
|
||||||
return await this.bot.browser.func.getSearchPoints()
|
return await this.bot.browser.func.getSearchPoints()
|
||||||
@@ -248,10 +258,11 @@ export class Search extends Workers {
|
|||||||
|
|
||||||
private async randomScroll(page: Page) {
|
private async randomScroll(page: Page) {
|
||||||
try {
|
try {
|
||||||
// Press the arrow down key to scroll
|
const scrollAmount = this.bot.utils.randomNumber(5, 5000)
|
||||||
for (let i = 0; i < this.bot.utils.randomNumber(5, 600); i++) {
|
|
||||||
await page.keyboard.press('ArrowDown')
|
await page.evaluate((scrollAmount) => {
|
||||||
}
|
window.scrollBy(0, scrollAmount)
|
||||||
|
}, scrollAmount)
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.bot.log('SEARCH-RANDOM-SCROLL', 'An error occurred:' + error, 'error')
|
this.bot.log('SEARCH-RANDOM-SCROLL', 'An error occurred:' + error, 'error')
|
||||||
|
|||||||
@@ -125,6 +125,8 @@ export class MicrosoftRewardsBot {
|
|||||||
|
|
||||||
// Desktop
|
// Desktop
|
||||||
async Desktop(account: Account) {
|
async Desktop(account: Account) {
|
||||||
|
this.isMobile = false
|
||||||
|
|
||||||
const browser = await this.browserFactory.createBrowser(account.proxy, account.email)
|
const browser = await this.browserFactory.createBrowser(account.proxy, account.email)
|
||||||
this.homePage = await browser.newPage()
|
this.homePage = await browser.newPage()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user