MsRewards-Reborn/V7/V7.py

84 lines
2.5 KiB
Python

from playwright.sync_api import sync_playwright, expect, Page
from playwright_stealth import stealth_sync
from logging import *
from actions.checks import check_logged_in
from actions.quiz import play_quiz_2, play_quiz_4, play_quiz_8, play_poll, detect_quiz_type, play
from actions.login import login
from actions.websearch import pc_search
basicConfig(encoding='utf-8', level=DEBUG)
def daily_cards(page: Page):
for i in range(1, 4):
card = page.locator(f'#daily-sets > mee-card-group:nth-child(7) > div > mee-card:nth-child({i}) > div')
with page.expect_popup() as page1_info:
card.click()
page1 = page1_info.value
stealth_sync(page1)
page1.wait_for_load_state('load')
try:
selector = page1.get_by_role("button", name="Accepter")
expect(selector).to_be_visible(timeout=10_000)
selector.click()
except AssertionError as e:
pass # The RGPD button should not be there in the first place
play(page1)
page1.close()
page.reload()
info(f'Carte {i} : {not "mee-icon-AddMedium" in card.inner_html()}')
def more_cards(page: Page):
c = 1
while c < 15: # todo I don't really know why it stops without raising any errors, but I guess it's fine
card = page.locator(f"#more-activities > div > mee-card:nth-child({c})")
try:
"mee-icon-AddMedium" in card.inner_html()
except AssertionError as e:
break
if "mee-icon-AddMedium" in card.inner_html():
info(f"Playing more cards {c}.")
with page.expect_popup() as page1_info:
card.click()
page1 = page1_info.value
stealth_sync(page1)
page1.wait_for_load_state('load')
play(page1)
page1.close()
page.reload()
info(f'Carte {c} : {not "mee-icon-AddMedium" in card.inner_html()}')
c += 1
def all_cards(page: Page):
# input("1")
page.goto("https://rewards.bing.com")
page.wait_for_load_state('load')
daily_cards(page)
more_cards(page)
def routine(page: Page) -> None:
all_cards(page)
pc_search(page)
with sync_playwright() as p:
browser = p.firefox.launch_persistent_context("./data/", headless=False)
page = browser.new_page()
stealth_sync(page)
login(page, input("mail ? "), input("password ? "))
all_cards(page)
browser.close()
"""
TODO :
Fidelity management.
Daily search
custom start
vnc
mobile search
"""