|
|
|
@ -5,18 +5,15 @@ from modules.config import *
|
|
|
|
|
from modules.tools import *
|
|
|
|
|
from modules.error import *
|
|
|
|
|
from modules.driver_tools import *
|
|
|
|
|
import modules.globals as g
|
|
|
|
|
|
|
|
|
|
global driver
|
|
|
|
|
driver = None
|
|
|
|
|
global _mail, _password, _otp, display
|
|
|
|
|
|
|
|
|
|
# TODO : replace by a better print (with logging, cf https://realpython.com/python-logging/)
|
|
|
|
|
def printf(e):
|
|
|
|
|
printf2(str(e), _mail)
|
|
|
|
|
driver = g.driver
|
|
|
|
|
display = g.display
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO
|
|
|
|
|
# handle "panda"'s error: error while logging in preventing some task to be done SadPanda.svg
|
|
|
|
|
# check that each card worked (lot of misses lately) -- test that -- don't crash at least
|
|
|
|
|
# handle "panda"'s error: error while logging in preventing some task to be done SadPanda.svg:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# create a webdriver
|
|
|
|
@ -43,11 +40,11 @@ def firefox_driver(mobile=False, headless=False):
|
|
|
|
|
if mobile :
|
|
|
|
|
options.set_preference("general.useragent.override", MOBILE_USER_AGENT)
|
|
|
|
|
driver = webdriver.Firefox(options=options)
|
|
|
|
|
driver.set_window_size(1070 + hash(_mail)%20 , 1900 + hash(_password + "salt")%10) # mobile resolution are crazy high now, right ?
|
|
|
|
|
driver.set_window_size(1070 + hash(g._mail)%20 , 1900 + hash(g._password + "salt")%10) # mobile resolution are crazy high now, right ?
|
|
|
|
|
else :
|
|
|
|
|
options.set_preference("general.useragent.override", PC_USER_AGENT)
|
|
|
|
|
driver = webdriver.Firefox(options=options)
|
|
|
|
|
driver.set_window_size(1900 + hash(_mail)%20 , 1070 + hash(_password + "salt")%10)
|
|
|
|
|
driver.set_window_size(1900 + hash(g._mail)%20 , 1070 + hash(g._password + "salt")%10)
|
|
|
|
|
return(driver)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -83,7 +80,7 @@ def log_error(error, ldriver=driver, log=FULL_LOG):
|
|
|
|
|
)
|
|
|
|
|
file = File("screenshot.png")
|
|
|
|
|
embed.set_image(url="attachment://screenshot.png")
|
|
|
|
|
embed.set_footer(text=_mail)
|
|
|
|
|
embed.set_footer(text=g._mail)
|
|
|
|
|
webhookFailure.send(embed=embed, username="error", file=file, avatar_url = AVATAR_URL)
|
|
|
|
|
webhookFailure.send(username="error", file=File("page.html"), avatar_url = AVATAR_URL)
|
|
|
|
|
|
|
|
|
@ -137,7 +134,7 @@ def play_quiz8():
|
|
|
|
|
counter = 0
|
|
|
|
|
# rgpd_popup(driver)
|
|
|
|
|
for _ in range(override):
|
|
|
|
|
custom_sleep(uniform(3, 5))
|
|
|
|
|
sleep(uniform(3, 5))
|
|
|
|
|
correct_answers = []
|
|
|
|
|
for i in range(1,9):
|
|
|
|
|
try :
|
|
|
|
@ -154,10 +151,10 @@ def play_quiz8():
|
|
|
|
|
try:
|
|
|
|
|
answer_elem = driver.find_element(By.ID, answer_id)
|
|
|
|
|
answer_elem.click()
|
|
|
|
|
custom_sleep(1)
|
|
|
|
|
sleep(1)
|
|
|
|
|
except exceptions.NoSuchElementException :
|
|
|
|
|
driver.refresh()
|
|
|
|
|
custom_sleep(10)
|
|
|
|
|
sleep(10)
|
|
|
|
|
answer_elem = driver.find_element(By.ID, answer_id)
|
|
|
|
|
answer_elem.click()
|
|
|
|
|
except ElementClickInterceptedException :
|
|
|
|
@ -213,160 +210,135 @@ def do_poll():
|
|
|
|
|
printf("do_poll : end")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# finds all task to do, and launch them
|
|
|
|
|
def all_cards(): # return to the main page and closes all other tabs
|
|
|
|
|
def reset(part2=False):
|
|
|
|
|
if len(driver.window_handles) == 1:
|
|
|
|
|
driver.get("https://www.bing.com/rewardsapp/flyout")
|
|
|
|
|
if part2:
|
|
|
|
|
row_element = driver.find_elements(By.CSS_SELECTOR, f'[class="i-h rw-sh fp_row"]')[1]
|
|
|
|
|
expanded = row_element.get_attribute("aria-expanded")
|
|
|
|
|
if expanded != "true":
|
|
|
|
|
row_element.click()
|
|
|
|
|
else:
|
|
|
|
|
def all_cards():
|
|
|
|
|
driver.get("https://rewards.bing.com")
|
|
|
|
|
liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
|
|
|
|
|
custom_sleep(2)
|
|
|
|
|
try :
|
|
|
|
|
promo()
|
|
|
|
|
except Exception as e:
|
|
|
|
|
#printf(format_error(e))
|
|
|
|
|
printf("no promo card")
|
|
|
|
|
|
|
|
|
|
for i in range(len(liste)):
|
|
|
|
|
printf(f"carte {i}")
|
|
|
|
|
try :
|
|
|
|
|
checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML"))
|
|
|
|
|
except StaleElementReferenceException :
|
|
|
|
|
liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
|
|
|
|
|
printf(f"staled, {len(liste)}")
|
|
|
|
|
checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML"))
|
|
|
|
|
if checked:
|
|
|
|
|
custom_sleep(3)
|
|
|
|
|
driver.execute_script("arguments[0].scrollIntoView();", liste[i])
|
|
|
|
|
liste[i].click()
|
|
|
|
|
if len(driver.window_handles) > 1 :
|
|
|
|
|
driver.switch_to.window(driver.window_handles[1])
|
|
|
|
|
printf(f"fermeture : {driver.current_url}")
|
|
|
|
|
driver.close()
|
|
|
|
|
driver.switch_to.window(driver.window_handles[0])
|
|
|
|
|
if driver.current_url != "https://www.bing.com/rewardsapp/flyout":
|
|
|
|
|
driver.get("https://www.bing.com/rewardsapp/flyout")
|
|
|
|
|
reset(part2)
|
|
|
|
|
|
|
|
|
|
def daily_cards(): # cartes de la premiere partie (renouvelée chaque jour).
|
|
|
|
|
try_play()
|
|
|
|
|
close_tab(driver.window_handles[1])
|
|
|
|
|
try :
|
|
|
|
|
# make sure that the daily area is expanded
|
|
|
|
|
row_element = driver.find_elements(By.CSS_SELECTOR, f'[class="i-h rw-sh fp_row"]')[0]
|
|
|
|
|
expanded = row_element.get_attribute("aria-expanded")
|
|
|
|
|
if expanded != "true":
|
|
|
|
|
row_element.click()
|
|
|
|
|
for i in range(3):
|
|
|
|
|
custom_sleep(uniform(3, 5))
|
|
|
|
|
driver.refresh()
|
|
|
|
|
liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
|
|
|
|
|
if ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML")) :
|
|
|
|
|
printf(f"carte {i} not okay. Retrying.")
|
|
|
|
|
liste[i].click()
|
|
|
|
|
driver.switch_to.window(driver.window_handles[1])
|
|
|
|
|
try_play()
|
|
|
|
|
close_tab(driver.window_handles[1])
|
|
|
|
|
except :
|
|
|
|
|
pass
|
|
|
|
|
else :
|
|
|
|
|
try :
|
|
|
|
|
titre = "Placeholder"
|
|
|
|
|
elm = driver.find_elements(By.CLASS_NAME, 'promo_cont')
|
|
|
|
|
elm[i].click()
|
|
|
|
|
sleep(1)
|
|
|
|
|
titre = driver.title
|
|
|
|
|
try_play(titre)
|
|
|
|
|
sleep(1)
|
|
|
|
|
reset()
|
|
|
|
|
printf(f"DailyCard {titre} ok")
|
|
|
|
|
welcome_tour(liste[i])
|
|
|
|
|
except Exception as e:
|
|
|
|
|
log_error(f"all_cards card {titre} error ({format_error(e)})")
|
|
|
|
|
"""
|
|
|
|
|
try : # devrait renvoyer vrai si la carte i est faite ou pas, a l'aide su symbole en haut a droite de la carte
|
|
|
|
|
elm = driver.find_element(By.XPATH, f"/html/body/div/div/div[3]/div[2]/div[1]/div[2]/div/div[{i+1}]/a/div/div[2]/div[1]/div[2]/div")
|
|
|
|
|
if not ("correctCircle" in elm.get_attribute("innerHTML")):
|
|
|
|
|
printf(f"missed card {i}")
|
|
|
|
|
try_play(titre)
|
|
|
|
|
sleep(3)
|
|
|
|
|
reset()
|
|
|
|
|
except Exception as e :
|
|
|
|
|
printf(format_error(e) + "probablement ok - check card")
|
|
|
|
|
# if it fail, it's probably okay -> when all three card are done, the pannel fold
|
|
|
|
|
"""
|
|
|
|
|
except Exception as e:
|
|
|
|
|
log_error(e)
|
|
|
|
|
print(format_error(e))
|
|
|
|
|
log_error("no new windows", driver)
|
|
|
|
|
custom_sleep(3)
|
|
|
|
|
|
|
|
|
|
def weekly_cards():
|
|
|
|
|
# make sure that the weekly area is expanded
|
|
|
|
|
row_element = driver.find_elements(By.CSS_SELECTOR, f'[class="i-h rw-sh fp_row"]')[1]
|
|
|
|
|
expanded = row_element.get_attribute("aria-expanded")
|
|
|
|
|
if expanded != "true":
|
|
|
|
|
row_element.click()
|
|
|
|
|
|
|
|
|
|
for i in range(20): # Should raise an error whene there is no card left
|
|
|
|
|
printf("début de l'une des cartes")
|
|
|
|
|
elm = driver.find_elements(By.CLASS_NAME, 'promo_cont')
|
|
|
|
|
def welcome_tour(elm):
|
|
|
|
|
try :
|
|
|
|
|
elm[0].click()
|
|
|
|
|
except Exception as e :
|
|
|
|
|
print(f"{e} + {driver.current_url}")
|
|
|
|
|
break
|
|
|
|
|
driver.find_element(By.CSS_SELECTOR, '[class="welcome-tour-next-button c-call-to-action c-glyph"]').click()
|
|
|
|
|
except :
|
|
|
|
|
pass
|
|
|
|
|
driver.find_element(By.CSS_SELECTOR, '[class="quiz-link gray-button c-call-to-action c-glyph f-lightweight"]').click()
|
|
|
|
|
sleep(5)
|
|
|
|
|
driver.find_element(By.CSS_SELECTOR, '[class="c-glyph glyph-cancel"]').click()
|
|
|
|
|
elm.click()
|
|
|
|
|
driver.find_element(By.CSS_SELECTOR, '[class="quiz-link gray-button c-call-to-action c-glyph f-lightweight"]').click()
|
|
|
|
|
sleep(5)
|
|
|
|
|
driver.find_element(By.CSS_SELECTOR, '[class="c-glyph glyph-cancel"]').click()
|
|
|
|
|
elm.click()
|
|
|
|
|
driver.find_element(By.CSS_SELECTOR, '[class="quiz-link gray-button c-call-to-action c-glyph f-lightweight"]').click()
|
|
|
|
|
sleep(5)
|
|
|
|
|
driver.find_element(By.CSS_SELECTOR, '[class="c-glyph glyph-cancel"]').click()
|
|
|
|
|
|
|
|
|
|
def spotify():
|
|
|
|
|
custom_sleep(5)
|
|
|
|
|
driver.find_element(By.CSS_SELECTOR, '[data-bi-id="spotify-premium gratuit"]').click()
|
|
|
|
|
custom_sleep(5)
|
|
|
|
|
close_tab(driver.window_handles[1])
|
|
|
|
|
|
|
|
|
|
def promo():
|
|
|
|
|
elm = driver.find_element(By.ID, "promo-item")
|
|
|
|
|
while elm:
|
|
|
|
|
driver.execute_script("arguments[0].click();", elm)
|
|
|
|
|
custom_sleep(3)
|
|
|
|
|
if len(driver.window_handles) > 1 :
|
|
|
|
|
driver.switch_to.window(driver.window_handles[len(driver.window_handles)-1])
|
|
|
|
|
sleep(1)
|
|
|
|
|
titre = driver.title
|
|
|
|
|
printf(f"carte {titre} en cours")
|
|
|
|
|
try_play(titre)
|
|
|
|
|
reset(True)
|
|
|
|
|
sleep(1)
|
|
|
|
|
#try:
|
|
|
|
|
# findall('href="([^<]+)" title=""', driver.page_source)[3] # return error if there is no cards left to do
|
|
|
|
|
#except:
|
|
|
|
|
# break
|
|
|
|
|
|
|
|
|
|
def top_cards():
|
|
|
|
|
for _ in range(2):
|
|
|
|
|
try_play()
|
|
|
|
|
close_tab(driver.window_handles[1])
|
|
|
|
|
else :
|
|
|
|
|
try :
|
|
|
|
|
driver.find_element(By.XPATH, "/html/body/div/div/div[3]/div[1]/div/div[1]/div[2]").click()
|
|
|
|
|
reset()
|
|
|
|
|
except Exception as e:
|
|
|
|
|
printf(format_error(e))
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
try :
|
|
|
|
|
#top_cards()
|
|
|
|
|
print("top card not working really well right now. They are currently disabled")
|
|
|
|
|
except Exception as e:
|
|
|
|
|
log_error(e)
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
daily_cards()
|
|
|
|
|
print("daily card")
|
|
|
|
|
except Exception as e:
|
|
|
|
|
log_error(e)
|
|
|
|
|
|
|
|
|
|
try :
|
|
|
|
|
weekly_cards()
|
|
|
|
|
print("weekly card")
|
|
|
|
|
except Exception as e:
|
|
|
|
|
log_error(e)
|
|
|
|
|
|
|
|
|
|
spotify()
|
|
|
|
|
except :
|
|
|
|
|
log_error("no new windows", driver)
|
|
|
|
|
custom_sleep(3)
|
|
|
|
|
|
|
|
|
|
# Find out which type of action to do
|
|
|
|
|
def try_play(nom="inconnu"):
|
|
|
|
|
rgpd_popup(driver)
|
|
|
|
|
printf("try_play en cours")
|
|
|
|
|
|
|
|
|
|
if (nom=="inconnu"):
|
|
|
|
|
nom = driver.title
|
|
|
|
|
def play(number):
|
|
|
|
|
if number == 8 or number == 9:
|
|
|
|
|
try:
|
|
|
|
|
printf(f"\033[96m Quiz 8 detected on {nom} \033[0m")
|
|
|
|
|
printf(f"\033[96mQuiz 8 detected on `{nom}` \033[0m")
|
|
|
|
|
play_quiz8()
|
|
|
|
|
printf(f"\033[92m Quiz 8 succeeded on {nom} \033[0m")
|
|
|
|
|
printf(f"\033[92mQuiz 8 succeeded on `{nom}` \033[0m")
|
|
|
|
|
custom_sleep(uniform(3, 5))
|
|
|
|
|
except Exception as e:
|
|
|
|
|
printf(f"fail of PlayQuiz 8. Aborted {e} \033[0m")
|
|
|
|
|
|
|
|
|
|
elif number == 5 or number == 4:
|
|
|
|
|
try:
|
|
|
|
|
printf(f"\033[96m Quiz 4 detected on {nom} \033[0m")
|
|
|
|
|
printf(f"\033[96mQuiz 4 detected on `{nom}` \033[0m")
|
|
|
|
|
play_quiz4()
|
|
|
|
|
printf(f"\033[92m Quiz 4 succeeded on {nom} \033[0m")
|
|
|
|
|
printf(f"\033[92mQuiz 4 succeeded on `{nom}` \033[0m")
|
|
|
|
|
custom_sleep(uniform(3, 5))
|
|
|
|
|
except Exception as e:
|
|
|
|
|
printf(f"fail of PlayQuiz 4. Aborted {e} \033[0m")
|
|
|
|
|
printf(f"Fail of PlayQuiz 4. Aborted {e} \033[0m")
|
|
|
|
|
|
|
|
|
|
elif number == 3 or number == 2:
|
|
|
|
|
try:
|
|
|
|
|
printf(f"\033[96m Quiz 2 detected on {nom}\033[0m")
|
|
|
|
|
printf(f"\033[96mQuiz 2 detected on `{nom}`\033[0m")
|
|
|
|
|
play_quiz2()
|
|
|
|
|
printf(f"\033[92m Quiz 2 succeeded on {nom}\033[0m")
|
|
|
|
|
printf(f"\033[92mQuiz 2 succeeded on `{nom}`\033[0m")
|
|
|
|
|
except Exception as e:
|
|
|
|
|
printf(f"fail of PlayQuiz 2. Aborted {e}")
|
|
|
|
|
else:
|
|
|
|
|
log_error("There is an error. rqAnswerOption present in page but no action to do. skipping.")
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
if wait_until_visible(By.ID, "rqStartQuiz", 5, driver):
|
|
|
|
|
custom_sleep(3)
|
|
|
|
|
driver.find_element(By.ID, "rqStartQuiz").click() # start the quiz
|
|
|
|
|
answer_number = driver.page_source.count("rqAnswerOption")
|
|
|
|
|
play(answer_number)
|
|
|
|
|
|
|
|
|
|
else :
|
|
|
|
|
raise (NameError("going to next part"))
|
|
|
|
|
except Exception as e: # if there is no start button, an error is thrown
|
|
|
|
|
if "bt_PollRadio" in driver.page_source:
|
|
|
|
|
try:
|
|
|
|
|
printf("Poll detected")
|
|
|
|
|
#rgpd_popup(driver)
|
|
|
|
|
do_poll()
|
|
|
|
|
printf("Poll succeeded")
|
|
|
|
|
except Exception as e:
|
|
|
|
@ -382,158 +354,93 @@ def try_play(nom="inconnu"):
|
|
|
|
|
|
|
|
|
|
elif search("([0-9]) de ([0-9]) finalisée", driver.page_source):
|
|
|
|
|
printf("fidélité")
|
|
|
|
|
#rgpd_popup(driver)
|
|
|
|
|
fidelity()
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
printf(f"rien à faire sur la page {nom}")
|
|
|
|
|
# rgpd_popup(driver)
|
|
|
|
|
custom_sleep(uniform(3, 5))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# login() tries to login to your Microsoft account.
|
|
|
|
|
# it uses global variable _mail and _password to login
|
|
|
|
|
def login(ldriver):
|
|
|
|
|
def pwd_login():
|
|
|
|
|
# Login with password or with cookies.
|
|
|
|
|
# The driver should be in the same state on both case
|
|
|
|
|
def pwd_login(ldriver):
|
|
|
|
|
printf("pwd_login : start")
|
|
|
|
|
ldriver.get("https://login.live.com")
|
|
|
|
|
custom_sleep(2)
|
|
|
|
|
wait_until_visible(By.ID, "i0116", browser = ldriver)
|
|
|
|
|
mail_elem = ldriver.find_element(By.ID, "i0116")
|
|
|
|
|
send_keys_wait(mail_elem, _mail)
|
|
|
|
|
send_keys_wait(mail_elem, g._mail)
|
|
|
|
|
mail_elem.send_keys(Keys.ENTER)
|
|
|
|
|
custom_sleep(2)
|
|
|
|
|
wait_until_visible(By.ID, "i0118", browser = ldriver)
|
|
|
|
|
pwd_elem = ldriver.find_element(By.ID, "i0118")
|
|
|
|
|
send_keys_wait(pwd_elem, _password)
|
|
|
|
|
send_keys_wait(pwd_elem, g._password)
|
|
|
|
|
pwd_elem.send_keys(Keys.ENTER)
|
|
|
|
|
custom_sleep(2)
|
|
|
|
|
# 2FA
|
|
|
|
|
if "Entrez le code de sécurité" in ldriver.page_source :
|
|
|
|
|
try :
|
|
|
|
|
a2f_elem = ldriver.find_element(By.ID, "idTxtBx_SAOTCC_OTC")
|
|
|
|
|
a2f_elem.send_keys(_otp.now())
|
|
|
|
|
a2f_elem.send_keys(g._otp.now())
|
|
|
|
|
a2f_elem.send_keys(Keys.ENTER)
|
|
|
|
|
except Exception as e :
|
|
|
|
|
log_error(e)
|
|
|
|
|
custom_sleep(5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def cookie_login(ldriver):
|
|
|
|
|
printf("cookies_login : start")
|
|
|
|
|
ldriver.get("https://login.live.com")
|
|
|
|
|
try :
|
|
|
|
|
load_cookies(ldriver)
|
|
|
|
|
except FileNotFoundError :
|
|
|
|
|
printf("No cookies file Found.")
|
|
|
|
|
return(False)
|
|
|
|
|
ldriver.refresh()
|
|
|
|
|
return(True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Accept all cookies question, and check if the account is locked
|
|
|
|
|
def login_part_2(ldriver, cookies = False):
|
|
|
|
|
custom_sleep(5)
|
|
|
|
|
if ('Abuse' in ldriver.current_url) :
|
|
|
|
|
log_error("account suspended")
|
|
|
|
|
raise Banned()
|
|
|
|
|
save_cookies(driver, _mail)
|
|
|
|
|
for id in ["KmsiCheckboxField","iLooksGood", "idSIButton9", "iCancel"]:
|
|
|
|
|
if cookies:
|
|
|
|
|
save_cookies(ldriver)
|
|
|
|
|
for id in ["KmsiCheckboxField", "id__0", "iLooksGood", "idSIButton9", "iCancel"]:
|
|
|
|
|
if get_domain(ldriver) == "account.microsoft.com":
|
|
|
|
|
break
|
|
|
|
|
try:
|
|
|
|
|
ldriver.find_element(By.ID, id).click()
|
|
|
|
|
restart = True
|
|
|
|
|
except Exception as e:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
try :
|
|
|
|
|
body_elem = ldriver.find_element(By.TAG_NAME, "body") # in case of any random popup
|
|
|
|
|
body_elem.send_keys(Keys.ENTER)
|
|
|
|
|
except :
|
|
|
|
|
pass
|
|
|
|
|
printf("login completed - going to MsRewards")
|
|
|
|
|
custom_sleep(uniform(3,5))
|
|
|
|
|
ldriver.get("https://www.bing.com/rewardsapp/flyout")
|
|
|
|
|
custom_sleep(uniform(3,5))
|
|
|
|
|
for i in [f'[title="Rejoindre maintenant"]', f'[title="Rejoindre"]', f'[title="Join now"]'] :
|
|
|
|
|
try:
|
|
|
|
|
ldriver.find_element(By.CSS_SELECTOR, i).click() # depend of the language of the page
|
|
|
|
|
except:
|
|
|
|
|
printf(f"element {i} not found")
|
|
|
|
|
wait_until_visible(By.CSS_SELECTOR, '[data-bi-id="sh-sharedshell-home"]', 20, ldriver)
|
|
|
|
|
ldriver.get("https://www.bing.com")
|
|
|
|
|
rgpd_popup(ldriver)
|
|
|
|
|
custom_sleep(uniform(3,5))
|
|
|
|
|
ldriver.get("https://www.bing.com/rewardsapp/flyout")
|
|
|
|
|
try:
|
|
|
|
|
ldriver.find_element(By.CSS_SELECTOR, '[title="Rejoindre maintenant"]').click() # depend of the language of the page
|
|
|
|
|
except:
|
|
|
|
|
printf(f"unlock test: fail, probably normal")
|
|
|
|
|
|
|
|
|
|
printf('on MsRewards')
|
|
|
|
|
|
|
|
|
|
def cookie_login():
|
|
|
|
|
ldriver.get("https://login.live.com")
|
|
|
|
|
try :
|
|
|
|
|
load_cookies(ldriver, _mail)
|
|
|
|
|
except FileNotFoundError :
|
|
|
|
|
printf("Creating cookies file")
|
|
|
|
|
return(False)
|
|
|
|
|
try :
|
|
|
|
|
ldriver.refresh()
|
|
|
|
|
except WebDriverException as e: # This error occurs at random time. Don't really know why
|
|
|
|
|
if "Reached error page: about:neterror?e=netTimeout" in str(e):
|
|
|
|
|
printf("Timeout error occurred. \"normal\"....., maybe because of mismatch date ? ")
|
|
|
|
|
log_error("Timeout error occurred. \"normal\"....., maybe because of mismatch date ?", ldriver, True) # TODO check this hypothesis
|
|
|
|
|
rgpd_popup(ldriver)
|
|
|
|
|
ldriver.get("https://account.microsoft.com/")
|
|
|
|
|
if wait_until_visible(By.CSS_SELECTOR, '[data-bi-id="sh-sharedshell-home"]', 30, ldriver) :
|
|
|
|
|
return(True) #the account logging was successful
|
|
|
|
|
else :
|
|
|
|
|
log_error(e, ldriver)
|
|
|
|
|
wait_until_visible(By.CSS_SELECTOR, '[data-bi-id="sh-sharedshell-rewards"]', 20, ldriver)
|
|
|
|
|
if ("account.microsoft.com" in ldriver.current_url) :
|
|
|
|
|
ldriver.get("https://bing.com")
|
|
|
|
|
custom_sleep(5)
|
|
|
|
|
log_error("Error during login. Trying to refresh")
|
|
|
|
|
ldriver.refresh()
|
|
|
|
|
rgpd_popup(ldriver) # Ultra important
|
|
|
|
|
ldriver.get("https://www.bing.com/rewardsapp/flyout")
|
|
|
|
|
#if "SadPanda.svg" in ldriver.page_source :
|
|
|
|
|
# log_error('test SadPanda before', ldriver)
|
|
|
|
|
# driver.execute_script("location.reload(true);")
|
|
|
|
|
# log_error('test SadPanda after', ldriver)
|
|
|
|
|
if not('>Tableau de bord' in ldriver.page_source):
|
|
|
|
|
try :
|
|
|
|
|
ldriver.find_element(By.CSS_SELECTOR, "[h='ID=RewardsFlyout,2.1']").click()
|
|
|
|
|
custom_sleep(5)
|
|
|
|
|
if "bing.com" in ldriver.current_url :
|
|
|
|
|
rgpd_popup(ldriver)
|
|
|
|
|
ldriver.get("https://www.bing.com/rewardsapp/flyout")
|
|
|
|
|
if ('>Tableau de bord' in ldriver.page_source) :
|
|
|
|
|
return(True)
|
|
|
|
|
else :
|
|
|
|
|
printf("error during the connection. Trying something else")
|
|
|
|
|
except Exception as e:
|
|
|
|
|
log_error(f"not connected 5 - error {e}", ldriver)
|
|
|
|
|
if not('>Tableau de bord' in ldriver.page_source):
|
|
|
|
|
try :
|
|
|
|
|
ldriver.find_element(By.XPATH, "/html/body/div/div/div/div/div[2]/a").click()
|
|
|
|
|
custom_sleep(5)
|
|
|
|
|
except Exception as e:
|
|
|
|
|
log_error(f"erreur not connected 6{e}", ldriver)
|
|
|
|
|
return(False)
|
|
|
|
|
if "bing.com" in ldriver.current_url :
|
|
|
|
|
rgpd_popup(ldriver)
|
|
|
|
|
ldriver.get("https://www.bing.com/rewardsapp/flyout")
|
|
|
|
|
if ('>Tableau de bord' in ldriver.page_source) :
|
|
|
|
|
return(True)
|
|
|
|
|
else :
|
|
|
|
|
log_error("not connected 6", ldriver)
|
|
|
|
|
return(False)
|
|
|
|
|
return(True)
|
|
|
|
|
return(wait_until_visible(By.CSS_SELECTOR, '[data-bi-id="sh-sharedshell-home"]', 30, ldriver))
|
|
|
|
|
|
|
|
|
|
if ('account.live.com' in ldriver.current_url):
|
|
|
|
|
log_error("error 1", ldriver, True)
|
|
|
|
|
ldriver.refresh()
|
|
|
|
|
log_error("error 2", ldriver, True)
|
|
|
|
|
ldriver.get("https://bing.com")
|
|
|
|
|
ldriver.refresh()
|
|
|
|
|
rgpd_popup(ldriver)
|
|
|
|
|
log_error("error 3", ldriver, True)
|
|
|
|
|
sleep(5)
|
|
|
|
|
return(True)
|
|
|
|
|
|
|
|
|
|
printf("cookies plus valides ?")
|
|
|
|
|
return(False)
|
|
|
|
|
|
|
|
|
|
# login() tries to login to your Microsoft account.
|
|
|
|
|
# it uses global variable g._mail and g._password to login
|
|
|
|
|
def login(ldriver):
|
|
|
|
|
try :
|
|
|
|
|
if cookie_login():
|
|
|
|
|
return (ldriver.current_window_handle)
|
|
|
|
|
pwd_login() #mobile login in never called. TODO : check if it's bad.
|
|
|
|
|
return(ldriver.current_window_handle)
|
|
|
|
|
success_cookies = cookie_login(ldriver)
|
|
|
|
|
if not success_cookies:
|
|
|
|
|
pwd_login(ldriver)
|
|
|
|
|
login_part_2(ldriver, not success_cookies)
|
|
|
|
|
ldriver.get("https://rewards.bing.com/")
|
|
|
|
|
except Banned:
|
|
|
|
|
raise Banned()
|
|
|
|
|
except Exception as e:
|
|
|
|
|
log_error(e)
|
|
|
|
|
ldriver.quit()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return(False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Makes 30 search as PC Edge
|
|
|
|
@ -559,9 +466,7 @@ def bing_pc_search(override=randint(35, 40)):
|
|
|
|
|
sleep(3)
|
|
|
|
|
send_keys_wait(driver.find_element(By.ID, "sb_form_q"), word)
|
|
|
|
|
driver.find_element(By.ID, "sb_form_q").send_keys(Keys.ENTER)
|
|
|
|
|
|
|
|
|
|
custom_sleep(uniform(5, 20))
|
|
|
|
|
|
|
|
|
|
custom_sleep(uniform(3, 7))
|
|
|
|
|
try:
|
|
|
|
|
driver.find_element(By.ID, "sb_form_q").clear()
|
|
|
|
|
except Exception as e:
|
|
|
|
@ -573,7 +478,6 @@ def bing_pc_search(override=randint(35, 40)):
|
|
|
|
|
log_error(f"clear la barre de recherche - {format_error(e)}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Unban an account, called with -u parameter. You will need a phone number
|
|
|
|
|
def unban() -> None:
|
|
|
|
|
driver.find_element(By.ID, "StartAction").click()
|
|
|
|
@ -607,23 +511,24 @@ def unban() -> None:
|
|
|
|
|
# Sends points to database, discord and whatever service you want
|
|
|
|
|
def log_points(account="unknown"):
|
|
|
|
|
def get_points():
|
|
|
|
|
driver.get("https://www.bing.com/rewardsapp/flyout")
|
|
|
|
|
regex1 = '<a href="https://rewards\.bing\.com/" title="((.{1,3}),(.{1,3})) points" target="_blank"'
|
|
|
|
|
driver.get("https://rewards.bing.com")
|
|
|
|
|
custom_sleep(1)
|
|
|
|
|
if "/proofs/" in driver.current_url:
|
|
|
|
|
for id in ["KmsiCheckboxField","iLooksGood", "idSIButton9", "iCancel"]:
|
|
|
|
|
try:
|
|
|
|
|
point = search(regex1, driver.page_source)[1].replace(",", "")
|
|
|
|
|
|
|
|
|
|
driver.find_element(By.ID, id).click()
|
|
|
|
|
restart = True
|
|
|
|
|
except Exception as e:
|
|
|
|
|
elem = driver.find_element(By.CSS_SELECTOR, '[title="Microsoft Rewards"]')
|
|
|
|
|
elem.click()
|
|
|
|
|
custom_sleep(5)
|
|
|
|
|
driver.switch_to.window(driver.window_handles[len(driver.window_handles) - 1])
|
|
|
|
|
custom_sleep(uniform(5,7))
|
|
|
|
|
pass
|
|
|
|
|
wait_until_visible(By.CSS_SELECTOR, 'span[mee-element-ready="$ctrl.loadCounterAnimation()"]', browser=driver)
|
|
|
|
|
try :
|
|
|
|
|
point = search('availablePoints":([\d]+)', driver.page_source)[1]
|
|
|
|
|
except :
|
|
|
|
|
point = search('availablePoints\":([\d]+)', driver.page_source)[1]
|
|
|
|
|
except Exception as e:
|
|
|
|
|
sleep(5)
|
|
|
|
|
log_error(f"Dev error, checking why it doesn't work (waited a bit, is this still white ?) {format_error(e)}", driver, True)
|
|
|
|
|
driver.refresh()
|
|
|
|
|
sleep(5)
|
|
|
|
|
point = search('availablePoints":([\d]+)', driver.page_source)[1]
|
|
|
|
|
point = search('availablePoints\":([\d]+)', driver.page_source)[1]
|
|
|
|
|
return(point)
|
|
|
|
|
|
|
|
|
|
for _ in range (3):
|
|
|
|
@ -677,7 +582,8 @@ def fidelity():
|
|
|
|
|
try :
|
|
|
|
|
choix = driver.find_element(By.CSS_SELECTOR, 'div[class="pull-left spacer-48-bottom punchcard-row"]') # pull-left spacer-48-bottom punchcard-row? USELESS ?
|
|
|
|
|
except : # tentative de fix
|
|
|
|
|
driver.refresh()
|
|
|
|
|
driver.execute_script("location.reload(true);")
|
|
|
|
|
wait_until_visible(By.CSS_SELECTOR, 'div[class="pull-left spacer-48-bottom punchcard-row"]', browser=driver)
|
|
|
|
|
choix = driver.find_element(By.CSS_SELECTOR, 'div[class="pull-left spacer-48-bottom punchcard-row"]')
|
|
|
|
|
answer_number = search("([0-9]) of ([0-9]) completed", driver.page_source)
|
|
|
|
|
if answer_number is None:
|
|
|
|
@ -719,60 +625,6 @@ def fidelity():
|
|
|
|
|
log_error(e)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def mobile_login_pwd(error):
|
|
|
|
|
try:
|
|
|
|
|
# TODO
|
|
|
|
|
# seems fine, check if there are no issues NO
|
|
|
|
|
mot = choice(Liste_de_mot).replace(" ","+")
|
|
|
|
|
mobile_driver.get(f"https://www.bing.com/search?q={mot}")
|
|
|
|
|
rgpd_popup(mobile_driver)
|
|
|
|
|
printf("start of Mobile login")
|
|
|
|
|
try :
|
|
|
|
|
mobile_driver.find_element(By.ID, "mHamburger").click()
|
|
|
|
|
except Exception as e :
|
|
|
|
|
elm = mobile_driver.find_element(By.ID, "mHamburger")
|
|
|
|
|
mobile_driver.execute_script("arguments[0].scrollIntoView();", elm)
|
|
|
|
|
mobile_driver.find_element(By.ID, "mHamburger").click()
|
|
|
|
|
|
|
|
|
|
wait_until_visible(By.ID, "hb_s", browser=mobile_driver)
|
|
|
|
|
mobile_driver.find_element(By.ID, "hb_s").click()
|
|
|
|
|
wait_until_visible(By.ID, "i0116", browser=mobile_driver)
|
|
|
|
|
mail_elem = mobile_driver.find_element(By.ID, "i0116")
|
|
|
|
|
send_keys_wait(mail_elem, _mail)
|
|
|
|
|
mail_elem.send_keys(Keys.ENTER)
|
|
|
|
|
wait_until_visible(By.ID, "i0118", browser=mobile_driver)
|
|
|
|
|
pwd_elem = mobile_driver.find_element(By.ID, "i0118")
|
|
|
|
|
send_keys_wait(pwd_elem, _password)
|
|
|
|
|
pwd_elem.send_keys(Keys.ENTER)
|
|
|
|
|
custom_sleep(uniform(1, 2))
|
|
|
|
|
if "Entrez le code de sécurité" in driver.page_source :
|
|
|
|
|
try :
|
|
|
|
|
a2f_elem = mobile_driver.find_element(By.ID, "idTxtBx_SAOTCC_OTC")
|
|
|
|
|
a2f_elem.send_keys(_otp.now())
|
|
|
|
|
a2f_elem.send_keys(Keys.ENTER)
|
|
|
|
|
except Exception as e :
|
|
|
|
|
log_error(e)
|
|
|
|
|
custom_sleep(uniform(1, 2))
|
|
|
|
|
for i in ["KmsiCheckboxField", "iLooksGood", "idSIButton9"]:
|
|
|
|
|
try:
|
|
|
|
|
mobile_driver.find_element(By.ID,i ).click()
|
|
|
|
|
except Exception as e:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
printf("end of Mobile login")
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
error += 1
|
|
|
|
|
if error <= 3:
|
|
|
|
|
printf(f"failure on mobile_login. Retrying({error}/3), {e}")
|
|
|
|
|
custom_sleep(uniform(5, 10))
|
|
|
|
|
mobile_login_pwd(error)
|
|
|
|
|
else:
|
|
|
|
|
log_error(f"login impossible 3 fois de suite. {e}", mobile_driver)
|
|
|
|
|
mobile_driver.quit()
|
|
|
|
|
return(True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def mobile_alert_popup():
|
|
|
|
|
try:
|
|
|
|
|
alert = mobile_driver.switch_to.alert
|
|
|
|
@ -798,7 +650,7 @@ def bing_mobile_search(override=randint(22, 25)):
|
|
|
|
|
mot = choice(Liste_de_mot)
|
|
|
|
|
send_keys_wait(mobile_driver.find_element(By.ID, "sb_form_q"), mot)
|
|
|
|
|
mobile_driver.find_element(By.ID, "sb_form_q").send_keys(Keys.ENTER)
|
|
|
|
|
custom_sleep(uniform(5, 20))
|
|
|
|
|
custom_sleep(uniform(3, 7))
|
|
|
|
|
mobile_alert_popup() # check for alert (asking for position or for allowing notifications)
|
|
|
|
|
mobile_driver.find_element(By.ID, "sb_form_q").clear()
|
|
|
|
|
except Exception as e:
|
|
|
|
@ -843,20 +695,20 @@ def daily_routine(custom = False):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
log_points(_mail)
|
|
|
|
|
log_points(g._mail)
|
|
|
|
|
except Exception as e:
|
|
|
|
|
log_error(e)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def dev():
|
|
|
|
|
log_error("test")
|
|
|
|
|
input("paused")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def CustomStart(Credentials):
|
|
|
|
|
global START_TIME
|
|
|
|
|
if not LINUX_HOST :
|
|
|
|
|
raise NameError('You need to be on linux to do that, due to the utilisation of a module named enquieries, sorry.')
|
|
|
|
|
global driver, _mail, _password, p, _otp
|
|
|
|
|
global driver, p
|
|
|
|
|
|
|
|
|
|
system("clear") # clear from previous command to allow a clean choice
|
|
|
|
|
actions = ["tout", "daily", "pc", "mobile", "log_points","fidelity", "dev"]
|
|
|
|
@ -865,10 +717,10 @@ def CustomStart(Credentials):
|
|
|
|
|
START_TIME = time() # Reset timer to the start of the actions
|
|
|
|
|
|
|
|
|
|
for cred in liste:
|
|
|
|
|
_mail = cred[0]
|
|
|
|
|
_password = cred[1]
|
|
|
|
|
g._mail = cred[0]
|
|
|
|
|
g._password = cred[1]
|
|
|
|
|
if len(cred) == 3:
|
|
|
|
|
_otp = TOTP(cred[2])
|
|
|
|
|
g._otp = TOTP(cred[2])
|
|
|
|
|
|
|
|
|
|
driver = firefox_driver()
|
|
|
|
|
driver.implicitly_wait(3)
|
|
|
|
@ -904,13 +756,12 @@ def CustomStart(Credentials):
|
|
|
|
|
break
|
|
|
|
|
if not "tout" in Actions:
|
|
|
|
|
try:
|
|
|
|
|
log_points(_mail)
|
|
|
|
|
log_points(g._mail)
|
|
|
|
|
except Exception as e:
|
|
|
|
|
printf(f"CustomStart {e}")
|
|
|
|
|
driver.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if VNC_ENABLED :
|
|
|
|
|
display = SmartDisplay(backend="xvnc", size=(2160, 2160), rfbport=VNC_PORT, color_depth=24)
|
|
|
|
|
else :
|
|
|
|
@ -921,7 +772,7 @@ display.start()
|
|
|
|
|
if CUSTOM_START:
|
|
|
|
|
CustomStart(Credentials)
|
|
|
|
|
elif UNBAN:
|
|
|
|
|
_mail, _password = select_accounts(False)[0]
|
|
|
|
|
g._mail, g._password = select_accounts(False)[0]
|
|
|
|
|
driver = firefox_driver()
|
|
|
|
|
try :
|
|
|
|
|
login(driver)
|
|
|
|
@ -934,18 +785,16 @@ elif POINTS_FILE != "":
|
|
|
|
|
else:
|
|
|
|
|
if UPDATE_VERSION != "None":
|
|
|
|
|
if DISCORD_ENABLED_ERROR:
|
|
|
|
|
webhookFailure.send(f"Updated to {UPDATE_VERSION}")
|
|
|
|
|
webhookFailure.send(f"Updated to {UPDATE_VERSION}", username="UPDATE", avatar_url="https://cdn-icons-png.flaticon.com/512/1688/1688988.png")
|
|
|
|
|
for cred in Credentials:
|
|
|
|
|
_mail = cred[0]
|
|
|
|
|
_password = cred[1]
|
|
|
|
|
g._mail = cred[0]
|
|
|
|
|
g._password = cred[1]
|
|
|
|
|
if len(cred) == 3:
|
|
|
|
|
_otp = TOTP(cred[2])
|
|
|
|
|
printf("\n\n")
|
|
|
|
|
printf(_mail)
|
|
|
|
|
g._otp = TOTP(cred[2])
|
|
|
|
|
custom_sleep(1)
|
|
|
|
|
printf("début du driver")
|
|
|
|
|
printf("Début du driver.")
|
|
|
|
|
driver = firefox_driver()
|
|
|
|
|
printf("driver demarré")
|
|
|
|
|
printf("Driver demarré.")
|
|
|
|
|
driver.implicitly_wait(3)
|
|
|
|
|
try:
|
|
|
|
|
daily_routine()
|
|
|
|
@ -954,11 +803,11 @@ else:
|
|
|
|
|
printf(f"finis. attente de {round(attente/60)}min")
|
|
|
|
|
custom_sleep(attente)
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
|
printf("canceled. Closing driver and display.")
|
|
|
|
|
printf("Canceled. Closing driver and display.")
|
|
|
|
|
driver.quit()
|
|
|
|
|
display.stop()
|
|
|
|
|
except Exception as e:
|
|
|
|
|
printf(f"error not catched. skipping this account. {e}")
|
|
|
|
|
printf(f"Error not catched. Skipping this account. {e}")
|
|
|
|
|
driver.quit()
|
|
|
|
|
|
|
|
|
|
display.stop()
|
|
|
|
|