Skip to content

Commit

Permalink
1.4.1
Browse files Browse the repository at this point in the history
- Fixed typos
- Added Dockerfile (experimental)
- Increased scroll amount
  • Loading branch information
TheNetsky committed Jan 14, 2024
1 parent 02518ee commit 15b2b82
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 5 deletions.
42 changes: 42 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Use an official Node.js runtime as a base image
FROM node:18

# Set the working directory in the container
WORKDIR /usr/src/microsoft-rewards-script

# Install jq
RUN apt-get update && apt-get install -y jq


# Copy all files to the working directory
COPY . .

# Check if "headless" is set to "true" in the config.json file
RUN HEADLESS=$(cat src/config.json | jq -r .headless) \
&& if [ "$HEADLESS" != "true" ]; then \
echo "Error: 'headless' in src/config.json is not true."; \
exit 1; \
fi

# Install dependencies including Playwright
RUN apt-get install -y \
xvfb \
libgbm-dev \
libnss3 \
libasound2 \
libxss1 \
libatk-bridge2.0-0 \
libgtk-3-0 \
&& rm -rf /var/lib/apt/lists/*

# Install application dependencies
RUN npm install

# Build the script
RUN npm run build

# Install playwright chromium
RUN npx playwright install chromium

# Define the command to run your application
CMD ["npm", "start"]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Under development, however mainly for personal use!
## 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 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`.

## Config ##
| Setting | Description | Default |
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "microsoft-rewards-script",
"version": "1.4.0",
"version": "1.4.1",
"description": "Automatically do tasks for Microsoft Rewards but in TS!",
"main": "index.js",
"engines": {
Expand All @@ -11,7 +11,8 @@
"start": "node ./dist/index.js",
"ts-start": "ts-node ./src/index.ts",
"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 ."
},
"keywords": [
"Bing Rewards",
Expand Down
2 changes: 1 addition & 1 deletion src/functions/Workers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class Workers {
}

// Solve Activities
this.bot.log('MORE-PROMOTIONS', 'Started solving "More Promotions" item')
this.bot.log('MORE-PROMOTIONS', 'Started solving "More Promotions" items')

page = await this.bot.browser.utils.getLatestTab(page)

Expand Down
4 changes: 2 additions & 2 deletions src/functions/activities/Search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export class Search extends Workers {
for (let i = 0; i < 5; i++) {
try {
const searchBar = '#sb_form_q'
await searchPage.waitForSelector(searchBar, { state: 'visible', timeout: 10_000 })
await searchPage.waitForSelector(searchBar, { state: 'attached', timeout: 10_000 })
await searchPage.click(searchBar) // Focus on the textarea
await this.bot.utils.wait(500)
await searchPage.keyboard.down('Control')
Expand Down Expand Up @@ -249,7 +249,7 @@ export class Search extends Workers {
private async randomScroll(page: Page) {
try {
// Press the arrow down key to scroll
for (let i = 0; i < this.bot.utils.randomNumber(5, 400); i++) {
for (let i = 0; i < this.bot.utils.randomNumber(5, 600); i++) {
await page.keyboard.press('ArrowDown')
}

Expand Down

0 comments on commit 15b2b82

Please sign in to comment.