Coder Social home page Coder Social logo

Comments (16)

TheNetsky avatar TheNetsky commented on August 23, 2024 1

Uh, not that I know of. You can just have 2 separate scrips each running 5 accounts.
Maybe that's something for the future but not right now.

from microsoft-rewards-script.

Willxwisp avatar Willxwisp commented on August 23, 2024

No Worries! I somehow made it work.. I don't know how but its a not that great but it gets the job done

from microsoft-rewards-script.

TheNetsky avatar TheNetsky commented on August 23, 2024

What is the solution you applied?

from microsoft-rewards-script.

Willxwisp avatar Willxwisp commented on August 23, 2024

This what I did on index.ts, but again super scuffed since no matter how I edit the search.ts it would sometimes miss a tab and I would need to manually close the opened link even if I make the timeout longer.

`

import Browser from './browser/Browser'
import { getDashboardData, getEarnablePoints, goHome } from './browser/BrowserFunc'
import { log } from './util/Logger'
import { loadAccounts } from './util/Account'
import { login } from './functions/Login'
import { doDailySet, doMorePromotions, doPunchCard } from './functions/Workers'
import { doSearch } from './functions/activities/Search'
import { Account } from './interface/Account'
import { runOnZeroPoints, workers } from './config.json'

// Main bot class
class MicrosoftRewardsBot {
	private collectedPoints: number = 0
	private browserFactory: Browser = new Browser()

	async run() {
		log('MAIN', 'Bot started')

		const accounts = await loadAccounts()

		// Split accounts into chunks of 5
		const accountChunks = chunkArray(accounts, 5)

		for (const accountChunk of accountChunks) {
			// Run tasks for each chunk concurrently
			await Promise.all(accountChunk.map(account => this.handleAccount(account)))
		}

		// Clean exit
		log('MAIN', 'Completed tasks for ALL accounts')
		log('MAIN', 'Bot exited')
		process.exit(0)
	}

	async handleAccount(account: Account) {
		log('MAIN', `Started tasks for account ${account.email}`)

		// Desktop Searches, DailySet and More Promotions
		await this.Desktop(account)

		// If runOnZeroPoints is false and 0 points to earn, stop and try the next account
		if (!runOnZeroPoints && this.collectedPoints === 0) {
			return
		}

		// Mobile Searches
		await this.Mobile(account)

		log('MAIN', `Completed tasks for account ${account.email}`)
	}

	async Desktop(account: Account) {
		const browser = await this.browserFactory.createBrowser(account.email, false)
		const page = await browser.newPage()

		log('MAIN', 'Starting DESKTOP browser')

		// Login into MS Rewards
		await login(page, account.email, account.password)

		const wentHome = await goHome(page)
		if (!wentHome) {
			throw log('MAIN', 'Unable to get dashboard page', 'error')
		}

		const data = await getDashboardData(page)
		log('MAIN-POINTS', `Current point count: ${data.userStatus.availablePoints}`)

		const earnablePoints = await getEarnablePoints(data)
		this.collectedPoints = earnablePoints
		log('MAIN-POINTS', `You can earn ${earnablePoints} points today`)

		// If runOnZeroPoints is false and 0 points to earn, don't continue
		if (!runOnZeroPoints && this.collectedPoints === 0) {
			log('MAIN', 'No points to earn and "runOnZeroPoints" is set to "false", stopping')

			// Close desktop browser
			return await browser.close()
		}

		// Complete daily set
		if (workers.doDailySet) {
			await doDailySet(page, data)
		}

		// Complete more promotions
		if (workers.doMorePromotions) {
			await doMorePromotions(page, data)
		}

		// Complete punch cards
		if (workers.doPunchCards) {
			await doPunchCard(page, data)
		}

		// Do desktop searches
		if (workers.doDesktopSearch) {
			await doSearch(page, data, false)
		}

		// Close desktop browser
		await browser.close()
	}

	async Mobile(account: Account) {
	  const browser = await this.browserFactory.createBrowser(account.email, true)
	  const page = await browser.newPage()

	  log('MAIN', 'Starting MOBILE browser')

	  // Login into MS Rewards
	  await login(page, account.email, account.password)

	  await goHome(page)

	  const data = await getDashboardData(page)

	  // If no mobile searches data found, stop (Does not exist on new accounts)
	  if (!data.userStatus.counters.mobileSearch) {
		  log('MAIN', 'No mobile searches found, stopping')

		  // Close mobile browser
		  return await browser.close()
	  }

	  // Do mobile searches
	  if (workers.doMobileSearch) {
		  await doSearch(page, data, true)
	  }

	  // Fetch new points
	  const earnablePoints = await getEarnablePoints(data, page)

	  // If the new earnable is 0, means we got all the points, else retract
	  this.collectedPoints = earnablePoints === 0 ? this.collectedPoints : (this.collectedPoints - earnablePoints)
	  log('MAIN-POINTS', `The script collected ${this.collectedPoints} points today`)

	  // Close mobile browser
	  await browser.close()
	}
}

function chunkArray(array: any[], chunkSize: number): any[][] {
	const results = [];
	
	while (array.length) {
		results.push(array.splice(0, chunkSize));
	}
	
	return results;
}

new MicrosoftRewardsBot().run()`

from microsoft-rewards-script.

TheNetsky avatar TheNetsky commented on August 23, 2024

It would be better to run each chunk in it's own worker, I might add that functionality.

Also does this search bug happen with Desktop or Mobile searches?

from microsoft-rewards-script.

TheNetsky avatar TheNetsky commented on August 23, 2024

Since it's in a "while loop" till the last tab is the search tab, it should always return.

Personally have not had it stuck with this, maybe add "console.log" after each condition to help debug where it gets stuck.

from microsoft-rewards-script.

Willxwisp avatar Willxwisp commented on August 23, 2024

So the problem I experienced was I think my network fluctuates from time to time there are instances where it would just take too long to load the url even making the timeout here longer didn't work:

await lastTab.waitForNetworkIdle({ idleTime: 1000, timeout: 5000 }).catch(() => { })
image

I mean I can just turn the randomclick off but I don't wanna risk getting suspended/restricted. So I made it like this:

        await lastTab.waitForSelector('body, html, head, title', { timeout: 10000 })
            .then(() => {
                setTimeout(() => {
                // Code to execute after waiting for 1 second
                }, 1000);
            })
            .catch(() => {
                // Code to execute if selector is not found
            });

Probably not the best way to do it since its kinda bruteforcing it but haven't ran into problem ever since.

from microsoft-rewards-script.

TheNetsky avatar TheNetsky commented on August 23, 2024

Uhm, by the error you've sent it does not occur in that function but more in the search function itself bingSearch(). Try increasing the timeout there

from microsoft-rewards-script.

TheNetsky avatar TheNetsky commented on August 23, 2024

Try adding searchpage.waitfornetworkidle after searchpage.keyboard.press('enter')

from microsoft-rewards-script.

Willxwisp avatar Willxwisp commented on August 23, 2024

So I monitored it before I tried fixing it, it would click a random link from the search results then it would just get stuck on that page then it would just be there, it would show the error that I saw on the command prompt, then if I close that tab it would just proceed as normal thats why I changed it to wait for selector

from microsoft-rewards-script.

TheNetsky avatar TheNetsky commented on August 23, 2024

So adding the "waitForNetworkIdle" on the location does not help?
Because it should throw the other error if it happened on the other function.

from microsoft-rewards-script.

Willxwisp avatar Willxwisp commented on August 23, 2024

Yupp it didn't work I tried the default one in your script with idle 1000 timeout 5000 didn't work, I increased the timeout to 10000 it worked but there's like 1 or 2 times that it would just get stuck again so I just opted for waitforselector.

This only happens because I putted it so that it would run 5 at the same time, if I made it like 2 at the same time there are no issues so I guess it's just my PC being slow

from microsoft-rewards-script.

TheNetsky avatar TheNetsky commented on August 23, 2024

I see, well it should retry even if it failed so in theory it should eventually do all the searches, also I'm looking into the parallel thing. But I need extra accounts to really check if it works, however the issue being here is that you need phone numbers because the accounts get "locked" otherwise, wondering how you "bypassed" this?

from microsoft-rewards-script.

Willxwisp avatar Willxwisp commented on August 23, 2024

Well you see, in our country its.. not that hard to just buy sim cards in bulk sure there has been new laws that has been passed that prevents us from buying sim cards in bulk but.. you just need to register your valid ID and connect it to your sim card, you can basically register unlimited sim cards it just needs to be registered and sim cards can be just bought in bulk anywhere so it's easy for me to farm 100 accounts if I wanted to. because if they do ban me they ban me like 40-45 days before they ban me and I could already redeem twice when that happens, also I can just remove all of my sim cards on my suspended accounts and use those on the new ones :>

from microsoft-rewards-script.

TheNetsky avatar TheNetsky commented on August 23, 2024

Damn, that's really convient. I'll experiment more with the timeouts, not sure if you can pinpoint exactly which function is the one calling the error. Since I assumed if it was the click function it would be caught by that catch block and not the searchBing one.

from microsoft-rewards-script.

TheNetsky avatar TheNetsky commented on August 23, 2024

Added clustering in 1.2.0 if you're interested in that.

from microsoft-rewards-script.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.