TheNetsky / Microsoft-Rewards-Script

Automated Microsoft Rewards script, using TypeScript, Cheerio and Playwright.
191 stars 43 forks source link

Doesnt do any searches, just closes. #159

Open Wasfgsd opened 13 hours ago

Wasfgsd commented 13 hours ago

Screenshot 2024-10-08 223635 The program closes as soon as it logs in and gets to the reward page, these are my settings in .config. I tried uninstalling/deleting the program and rebuilding it, but it does the same thing. image

Wasfgsd commented 12 hours ago

Even trying older builds that worked, going into the appdata/local folder and deleting any cache and playwright files and it still no longer works, I'm unsure what's gone wrong.

devallareddyb commented 10 hours ago

Even trying older builds that worked, going into the appdata/local folder and deleting any cache and playwright files and it still no longer works, I'm unsure what's gone wrong.

Disable puchcards, it should work

devallareddyb commented 8 hours ago

May be this can help if you update Workers.ts

// Punch Card async doPunchCard(page: Page, data: DashboardData) { // Filter uncompleted punch cards, ensuring parentPromotion exists const punchCardsUncompleted = data.punchCards?.filter(x => x.parentPromotion && !x.parentPromotion.complete) ?? [];

if (!punchCardsUncompleted.length) {
    this.bot.log('PUNCH-CARD', 'All "Punch Cards" have already been completed');
    return;
}

for (const punchCard of punchCardsUncompleted) {
    // Ensure parentPromotion exists before proceeding
    if (!punchCard.parentPromotion) {
        this.bot.log('PUNCH-CARD', 'Skipping punchcard: Parent promotion is missing or null');
        continue; // Skip this punch card
    }

    // Get latest page for each card
    page = await this.bot.browser.utils.getLatestTab(page);

    const activitiesUncompleted = punchCard.childPromotions.filter(x => !x.complete); // Only return uncompleted activities

    // Solve Activities
    this.bot.log('PUNCH-CARD', `Started solving "Punch Card" items for punchcard: "${punchCard.parentPromotion.title}"`);

    // Go to punch card index page in a new tab
    await page.goto(punchCard.parentPromotion.destinationUrl, { referer: this.bot.config.baseURL });

    // Wait for new page to load, max 10 seconds, however try regardless in case of error
    await page.waitForLoadState('networkidle', { timeout: 5000 }).catch(() => {});

    await this.solveActivities(page, activitiesUncompleted, punchCard);

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

    const pages = page.context().pages();

    if (pages.length > 3) {
        await page.close();
    } else {
        await this.bot.browser.func.goHome(page);
    }

    this.bot.log('PUNCH-CARD', `All items for punchcard: "${punchCard.parentPromotion.title}" have been completed`);
}

this.bot.log('PUNCH-CARD', 'All "Punch Card" items have been completed');

}

TheNetsky commented 3 hours ago

Never seen this happen before, but I will add a check for it, most likely exactly as given above.