je suis ptet en train de tout refaire mais chut

This commit is contained in:
piair 2024-01-17 17:22:26 +01:00
parent 7d81eb642e
commit d5ec96f1e8
8 changed files with 346205 additions and 176 deletions

362
V6.py
View File

@ -8,7 +8,6 @@ from modules.driver_tools import *
from modules.cards import *
import modules.globals as g
driver = g.driver
display = g.display
@ -19,7 +18,7 @@ def firefox_driver(mobile=False, headless=False):
"Mozilla/5.0 (X11; Linux x86_64)"
"AppleWebKit/537.36 (KHTML, like Gecko)"
"Chrome/118.0.0.0 Safari/537.36 Edg/118.0.2088.46"
)
)
MOBILE_USER_AGENT = (
"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N)"
"AppleWebKit/537.36 (KHTML, like Gecko)"
@ -28,34 +27,34 @@ def firefox_driver(mobile=False, headless=False):
chrome_options = webdriver.ChromeOptions()
if mobile:
chrome_options.add_argument(f"--user-agent={MOBILE_USER_AGENT}")
else :
else:
chrome_options.add_argument(f"--user-agent={PC_USER_AGENT}")
# disabled as it may cause detection
if g.proxy_enabled:
PROXY = f"{g.proxy_address}:{g.proxy_port}" # IP:PORT or HOST:PORT
PROXY = f"{g.proxy_address}:{g.proxy_port}" # IP:PORT or HOST:PORT
chrome_options.add_argument(f'--proxy-server={PROXY}')
driver = uc.Chrome(options=chrome_options)
set_language(driver)
return(driver)
return (driver)
def log_error(error, ldriver=driver, log=g.full_log):
global driver
if ldriver is None:
ldriver = driver
if type(error) != str :
if type(error) != str:
error = format_error(error)
printf(f"\n\n\033[93m Erreur : {str(error)} \033[0m\n\n")
if g.discord_enabled_error:
with open("page.html", "w") as f:
try :
try:
f.write(ldriver.page_source)
except :
except:
f.write("the driver has closed or crashed. Can't access page content")
try :
try:
img = display.waitgrab()
img.save("screenshot.png")
except :
except:
ldriver.save_screenshot("screenshot.png")
if not log:
embed = Embed(
@ -72,8 +71,8 @@ def log_error(error, ldriver=driver, log=g.full_log):
file = File("screenshot.png")
embed.set_image(url="attachment://screenshot.png")
embed.set_footer(text=g._mail)
webhookFailure.send(embed=embed, username="error", file=file, avatar_url = g.avatar_url)
webhookFailure.send(username="error", file=File("page.html"), avatar_url = g.avatar_url)
webhookFailure.send(embed=embed, username="error", file=file, avatar_url=g.avatar_url)
webhookFailure.send(username="error", file=File("page.html"), avatar_url=g.avatar_url)
# close the tab currently on and go back to the one first, or the one specified
@ -83,7 +82,6 @@ def close_tab(tab, SwitchTo=0) -> None:
driver.switch_to.window(driver.window_handles[SwitchTo])
# play_quiz[N]([int : override]) make the quiz with N choice each time. They usually have between 4 and 10 questions.
# override is the number of question, by default, it's the number of question in this specific quiz. Can be useful in some case, where the program crashes before finishing the quiz
def play_quiz2(override=10) -> None:
@ -124,37 +122,37 @@ def play_quiz2(override=10) -> None:
def play_quiz8():
override = len(findall("<span id=\"rqQuestionState.\" class=\"emptyCircle\"></span>", driver.page_source))+1
override = len(findall("<span id=\"rqQuestionState.\" class=\"emptyCircle\"></span>", driver.page_source)) + 1
printf(f"play_quiz8 : start, override : {override}")
try:
counter = 0
# rgpd_popup(driver)
for _ in range(override):
for _ in range(override):
sleep(uniform(3, 5))
correct_answers = []
for i in range(1,9):
try :
element = driver.find_element(By.ID, f"rqAnswerOption{i-1}")
for i in range(1, 9):
try:
element = driver.find_element(By.ID, f"rqAnswerOption{i - 1}")
if 'iscorrectoption="True"' in element.get_attribute("outerHTML"):
correct_answers.append(f'rqAnswerOption{i-1}')
except Exception as e :
printf(f"can't find rqAnswerOption{i-1}. Probably already clicked" + str(e))
correct_answers.append(f'rqAnswerOption{i - 1}')
except Exception as e:
printf(f"can't find rqAnswerOption{i - 1}. Probably already clicked" + str(e))
shuffle(correct_answers)
for answer_id in correct_answers:
wait_until_visible(By.ID, answer_id, timeout = 20, browser=driver)
wait_until_visible(By.ID, answer_id, timeout=20, browser=driver)
counter += 1
if g.log :
if g.log:
progressBar(counter, 16, name="Quiz 8")
try:
answer_elem = driver.find_element(By.ID, answer_id)
answer_elem.click()
sleep(1)
except exceptions.NoSuchElementException :
except exceptions.NoSuchElementException:
driver.refresh()
sleep(10)
answer_elem = driver.find_element(By.ID, answer_id)
answer_elem.click()
except ElementClickInterceptedException :
except ElementClickInterceptedException:
rgpd_popup(driver)
correct_answers.append(answer_id)
@ -178,7 +176,7 @@ def play_quiz4(override=None):
txt = driver.page_source
# rgpd_popup(driver)
answer_option = search('correctAnswer":"([^"]+)', txt)[1]
answer_option = answer_option.replace("\\u0027", "'") # replace Unicode weird symbols
answer_option = answer_option.replace("\\u0027", "'") # replace Unicode weird symbols
try:
answer_element = driver.find_element(By.CSS_SELECTOR, f'[data-option="{answer_option}"]')
answer_element.click()
@ -196,7 +194,7 @@ def do_poll():
printf("do_poll : start")
try:
try:
answer_elem = driver.find_element(By.ID, f"btoption{choice([0,1])}")
answer_elem = driver.find_element(By.ID, f"btoption{choice([0, 1])}")
answer_elem.click()
except exceptions.ElementNotInteractableException:
driver.execute_script("arguments[0].click();", answer_elem)
@ -208,30 +206,30 @@ def do_poll():
def all_cards():
#input("1")
# input("1")
driver.get("https://rewards.bing.com")
wait_until_visible(By.CLASS_NAME, "c-card-content", 10, driver)
liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
custom_sleep(2)
try :
try:
promo()
except Exception as e:
printf("no promo card")
if(len(liste) < 10): #most likely an error during loading
if (len(liste) < 10): # most likely an error during loading
if "suspendu" in driver.page_source:
raise Banned()
driver.refresh()
liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
if(len(liste) < 10):
if (len(liste) < 10):
log_error("Less than 10 cards. Most likely an error with login.", driver)
return("PAS ASSEZ DE CARTES")
if (len(liste) < 20): # most likely not in france
return ("PAS ASSEZ DE CARTES")
if (len(liste) < 20): # most likely not in france
printf("moins de 20 cartes. Probablement pas en France.")
for i in range(len(liste)):
printf(f"carte {i}")
try :
try:
checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML"))
except StaleElementReferenceException :
except StaleElementReferenceException:
driver.refresh()
liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
printf(f"staled, {len(liste)}")
@ -240,32 +238,32 @@ def all_cards():
driver.get("https://rewards.bing.com")
custom_sleep(10)
liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
try :
try:
checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML"))
except IndexError :
if i == len(liste) & i > 15 :
except IndexError:
if i == len(liste) & i > 15:
checked = False
#input("2")
# input("2")
if checked:
custom_sleep(1.5)
driver.execute_script("arguments[0].scrollIntoView();", liste[i])
custom_sleep(1.5)
#input("3")
# input("3")
liste[i].click()
#input("4")
if len(driver.window_handles) > 1 :
# input("4")
if len(driver.window_handles) > 1:
driver.switch_to.window(driver.window_handles[1])
#input("5")
# input("5")
try_play(driver.title)
close_tab(driver.window_handles[1])
try :
try:
driver.refresh()
liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
if ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML")) :
if ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML")):
printf(f"carte {i} not okay. Retrying.")
try :
try:
liste[i].click()
except :
except:
log_error("problème inconnu ? sauf si c'est un element obscure...", driver)
driver.get("https://rewards.bing.com")
checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML"))
@ -281,17 +279,17 @@ def all_cards():
custom_sleep(10)
log_error(f"Cart completion - log - 3 - after 10 sec", driver)
try:
try_play(driver.title) # go back to the main page
try :
try_play(driver.title) # go back to the main page
try:
close_tab(driver.window_handles[1])
except:
pass
except :
except:
driver.get("https://rewards.bing.com")
except :
except:
pass
else :
try :
else:
try:
welcome_tour(liste[i], driver)
except Exception as e:
printf("no new windows" + format_error(e))
@ -305,29 +303,30 @@ def promo():
wait_until_visible(By.ID, "promo-item", 5, driver)
if not elm:
break
if i > 3 :
if i > 3:
log_error("plus de 3 promo cards, probablement une pa skipable", driver)
try :
driver.find_element(By.CSS_SELECTOR, 'i[class="mee-icon pull-left icon mee-icon-Cancel ng-scope"]').click()
try:
driver.find_element(By.CSS_SELECTOR,
'i[class="mee-icon pull-left icon mee-icon-Cancel ng-scope"]').click()
except Exception as e:
log_error(f"can't click to close : {e}")
return()
try :
return ()
try:
elm.click()
except Exception as e:
#log_error(e, driver)
# log_error(e, driver)
driver.execute_script("arguments[0].click();", elm)
#log_error(e, driver)
# log_error(e, driver)
printf(f"that should't be there (promo), but the workarround seemed to work {e}")
custom_sleep(3)
if len(driver.window_handles) > 1 :
driver.switch_to.window(driver.window_handles[len(driver.window_handles)-1])
if len(driver.window_handles) > 1:
driver.switch_to.window(driver.window_handles[len(driver.window_handles) - 1])
try_play(driver.title)
close_tab(driver.window_handles[1])
else :
try :
else:
try:
spotify(driver)
except :
except:
printf("no new windows", driver)
driver.get("https://rewards.bing.com")
driver.refresh()
@ -337,6 +336,7 @@ def promo():
# Find out which type of action to do
def try_play(nom="inconnu"):
rgpd_popup(driver)
def play(number):
if number == 8 or number == 9:
try:
@ -383,9 +383,9 @@ def try_play(nom="inconnu"):
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
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")
@ -398,7 +398,7 @@ def try_play(nom="inconnu"):
try:
number = driver.page_source.count("rqAnswerOption")
printf(f"recovery détecté. quiz : {number}")
play(number-1)
play(number - 1)
except Exception as e:
printf(f"try_play - 2 - {e}")
@ -413,60 +413,60 @@ def try_play(nom="inconnu"):
# Login with password or with cookies.
# The driver should be in the same state on both case
def pwd_login(ldriver):
def pwd_login(ldriver):
printf("pwd_login : start")
ldriver.get("https://login.live.com")
wait_until_visible(By.ID, "i0116", browser = ldriver)
wait_until_visible(By.ID, "i0116", browser=ldriver)
mail_elem = ldriver.find_element(By.ID, "i0116")
send_keys_wait(mail_elem, g._mail)
mail_elem.send_keys(Keys.ENTER)
wait_until_visible(By.ID, "i0118", browser = ldriver)
wait_until_visible(By.ID, "i0118", browser=ldriver)
pwd_elem = ldriver.find_element(By.ID, "i0118")
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 :
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(g._otp.now())
a2f_elem.send_keys(Keys.ENTER)
except Exception as e :
except Exception as e:
log_error(e)
def cookie_login(ldriver):
printf("cookies_login : start")
ldriver.get("https://login.live.com")
try :
try:
load_cookies(ldriver)
except FileNotFoundError :
except FileNotFoundError:
printf("No cookies file Found.")
return(False)
return (False)
except Exception as e:
#log_error(f"Error performing cookies login. Trying with password instead. \n{str(e)}", driver)
# log_error(f"Error performing cookies login. Trying with password instead. \n{str(e)}", driver)
print("error with cookies login. IDK why (yet)")
return(False)
try :
return (False)
try:
ldriver.refresh()
except Exception as e:
printf(format_error(e))
printf("FIX YOUR SITE MS.......")
return(True)
return (True)
# Accept all cookies question, and check if the account is locked
def login_part_2(ldriver, cookies = False):
def login_part_2(ldriver, cookies=False):
custom_sleep(5)
if ('Abuse' in ldriver.current_url) :
if ('Abuse' in ldriver.current_url):
raise Banned()
if ('identity' in ldriver.current_url) :
if ('identity' in ldriver.current_url):
raise Identity()
if ('notice' in ldriver.current_url) :
if ('notice' in ldriver.current_url):
ldriver.find_element(By.ID, "id__0").click()
if ("proof" in ldriver.current_url):
ldriver.find_element(BY.ID, "iLooksGood")
ldriver.find_element(By.ID, "iLooksGood")
if cookies:
save_cookies(ldriver)
for id in ["iNext", "KmsiCheckboxField", "id__0", "iLooksGood", "idSIButton9", "iCancel"]:
@ -479,11 +479,10 @@ def login_part_2(ldriver, cookies = False):
wait_until_visible(By.CSS_SELECTOR, '[data-bi-id="sh-sharedshell-home"]', 20, ldriver)
# login() tries to login to your Microsoft account.
# it uses global variable g._mail and g._password to login
def login(ldriver):
try :
try:
pwd_login(ldriver)
login_part_2(ldriver, 0)
ldriver.get("https://rewards.bing.com/")
@ -494,18 +493,18 @@ def login(ldriver):
except Exception as e:
log_error(e)
ldriver.quit()
return(False)
return (False)
# Makes 30 search as PC Edge
def bing_pc_search(override=randint(35, 40)):
mot = choice(Liste_de_mot).replace(" ","+")
mot = choice(Liste_de_mot).replace(" ", "+")
driver.get(f"https://www.bing.com/search?q={mot}") # {choice(Liste_de_mot)}')
custom_sleep(uniform(1, 2))
rgpd_popup(driver)
send_keys_wait(
driver.find_element(By.ID, "sb_form_q"),
Keys.BACKSPACE + Keys.BACKSPACE + Keys.BACKSPACE + Keys.BACKSPACE + Keys.BACKSPACE + Keys.BACKSPACE
Keys.BACKSPACE + Keys.BACKSPACE + Keys.BACKSPACE + Keys.BACKSPACE + Keys.BACKSPACE + Keys.BACKSPACE
)
for _ in range(override):
@ -513,7 +512,7 @@ def bing_pc_search(override=randint(35, 40)):
try:
send_keys_wait(driver.find_element(By.ID, "sb_form_q"), word)
driver.find_element(By.ID, "sb_form_q").send_keys(Keys.ENTER)
except Exception as e :
except Exception as e:
printf(e)
sleep(10)
driver.get(f'https://www.bing.com/search?q={word}')
@ -563,30 +562,33 @@ def unban() -> None:
# Sends points to database, discord and whatever service you want
def log_points(account="unknown"):
def log_points(account="unknown"):
def get_points():
driver.get("https://rewards.bing.com")
custom_sleep(1)
if "/proofs/" in driver.current_url:
webhookFailure.send(f"Is /proof Useful in logpoints?", username="Dev tests", avatar_url="https://cdn.discordapp.com/attachments/793934298977009677/1144560898879541268/image.png")
for id in ["KmsiCheckboxField","iLooksGood", "idSIButton9", "iCancel"]:
webhookFailure.send(f"Is /proof Useful in logpoints?", username="Dev tests",
avatar_url="https://cdn.discordapp.com/attachments/793934298977009677/1144560898879541268/image.png")
for id in ["KmsiCheckboxField", "iLooksGood", "idSIButton9", "iCancel"]:
try:
driver.find_element(By.ID, id).click()
except Exception as e:
pass
wait_until_visible(By.CSS_SELECTOR, 'span[mee-element-ready="$ctrl.loadCounterAnimation()"]', browser=driver)
try :
try:
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)
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]
return(point)
return (point)
for _ in range (3):
try :
for _ in range(3):
try:
points = get_points()
break
except Exception as e:
@ -594,7 +596,7 @@ def log_points(account="unknown"):
log_error(e)
points = None
if not points :
if not points:
log_error(f"impossible d'avoir les points")
custom_sleep(uniform(3, 20))
@ -610,38 +612,40 @@ def log_points(account="unknown"):
else:
webhookSuccess.send(f"{account_name} actuellement à {str(points)} points")
try :
try:
add_to_database(account_name, points)
except Exception as e:
log_error(e)
def fidelity():
def sub_fidelity():
def sub_fidelity():
try:
wait_until_visible(By.CSS_SELECTOR, 'div[class="pull-left spacer-48-bottom punchcard-row"]', browser=driver)
answer_number = search("([0-9]) of ([0-9]) completed", driver.page_source)
if answer_number is None :
if answer_number is None:
answer_number = search("([0-9])&nbsp;défi\(s\) terminé\(s\) sur ([0-9])", driver.page_source)
if answer_number is None:
answer_number = search("([0-9]) de ([0-9]) finalisé", driver.page_source)
if answer_number is None :
if answer_number is None:
answer_number = search("([0-9]) licence\(s\) sur ([0-9]) disponible\(s\)", driver.page_source)
if answer_number is None :
answer_number = [0,0,0]
if answer_number is None:
answer_number = [0, 0, 0]
for _ in range(int(answer_number[2]) - int(answer_number[1])):
driver.refresh()
custom_sleep(2)
card_elem = driver.find_element(By.CLASS_NAME, "spacer-48-bottom")
try :
button_text = search('<span class="pull-left margin-right-15">([^<^>]+)</span>',card_elem.get_attribute("innerHTML"))[1]
try:
button_text = search('<span class="pull-left margin-right-15">([^<^>]+)</span>',
card_elem.get_attribute("innerHTML"))[1]
bouton_card = driver.find_element(By.XPATH, f'//span[text()="{button_text}"]')
bouton_card.click()
except Exception as e1 :
try :
recover_elem = driver.find_element(By.XPATH,'/html/body/div[1]/div[2]/main/div[2]/div[2]/div[7]/div[3]/div[1]/a')
except Exception as e1:
try:
recover_elem = driver.find_element(By.XPATH,
'/html/body/div[1]/div[2]/main/div[2]/div[2]/div[7]/div[3]/div[1]/a')
recover_elem.click()
except Exception as e2 :
except Exception as e2:
log_error(f"fidélité - double erreur - e1 : {format_error(e1)} - e2 {format_error(e2)}")
break
custom_sleep(uniform(3, 5))
@ -655,33 +659,36 @@ def fidelity():
printf("fidelity - done")
except Exception as e:
log_error(e)
if driver.current_url != "https://rewards.bing.com":
driver.get("https://rewards.bing.com")
try :
pause = driver.find_element(By.CSS_SELECTOR, f'[class="c-action-toggle c-glyph f-toggle glyph-pause"]') # mettre le truc en pause
try:
pause = driver.find_element(By.CSS_SELECTOR,
f'[class="c-action-toggle c-glyph f-toggle glyph-pause"]') # mettre le truc en pause
pause.click()
except Exception as e:
printf(f"erreur lors du click de pause: probablement pas de cartes {e}")
return("no cards")
return ("no cards")
cartes = driver.find_elements(By.CSS_SELECTOR, f'[ng-repeat="item in $ctrl.transcludedItems"]')
nb_cartes = len(cartes)
checked_list_all = driver.find_elements(By.CSS_SELECTOR, f'[ng-if="$ctrl.complete"]')
for i in range(nb_cartes):
cartes[i].click() # affiche la bonne carte
cartes[i].click() # affiche la bonne carte
checked_txt = checked_list_all[i].get_attribute("innerHTML")
ok = checked_txt.count("StatusCircleOuter checkmark")
total = checked_txt.count("StatusCircleOuter")
if (ok != total) :
if (ok != total):
elm = driver.find_elements(By.CLASS_NAME, 'clickable-link')[i]
if not "moviesandtv" in elm.get_attribute("innerHTML"): # not the film card
if not "moviesandtv" in elm.get_attribute("innerHTML"): # not the film card
elm.click()
driver.switch_to.window(driver.window_handles[len(driver.window_handles)-1])
driver.switch_to.window(driver.window_handles[len(driver.window_handles) - 1])
sub_fidelity()
close_tab(driver.window_handles[1])
custom_sleep(1)
cartes = driver.find_elements(By.CSS_SELECTOR, f'[ng-repeat="item in $ctrl.transcludedItems"]')
checked_list_all = driver.find_elements(By.CSS_SELECTOR, f'[ng-if="$ctrl.complete"]')
def mobile_alert_popup():
try:
alert = mobile_driver.switch_to.alert
@ -697,13 +704,13 @@ def bing_mobile_search(override=randint(22, 25)):
mobile_driver = firefox_driver(mobile=True)
try:
login(mobile_driver)
mot = choice(Liste_de_mot).replace(" ","+")
mot = choice(Liste_de_mot).replace(" ", "+")
mobile_driver.get(f"https://www.bing.com/search?q={mot}")
custom_sleep(uniform(1, 2))
rgpd_popup(mobile_driver)
custom_sleep(uniform(1, 1.5))
for i in range(override): # 20
try :
try:
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)
@ -722,22 +729,22 @@ def bing_mobile_search(override=randint(22, 25)):
mobile_driver.quit()
def daily_routine(custom = False):
try :
if not custom: # custom already login
def daily_routine(custom=False):
try:
if not custom: # custom already login
login(driver)
except Banned :
except Banned:
log_error("This account is locked. Fix that. (-U ?)", driver)
return()
except Identity :
return ()
except Identity:
log_error("This account has an issue. Fix that.", driver)
return()
return ()
try:
all_cards()
except Banned:
log_error("banned", driver)
return("BANNED")
return ("BANNED")
except Exception as e:
log_error(e)
@ -766,17 +773,17 @@ def dev():
pass
def CustomStart():
if not g.islinux :
raise NameError('You need to be on linux to do that, due to the utilisation of a module named enquieries, sorry.')
if not g.islinux:
raise NameError(
'You need to be on linux to do that, due to the utilisation of a module named enquieries, sorry.')
global driver
system("clear") # clear from previous command to allow a clean choice
actions = ["tout", "daily", "pc", "mobile", "log_points","fidelity", "dev"]
actions = ["tout", "daily", "pc", "mobile", "log_points", "fidelity", "dev"]
Actions = enquiries.choose("quels Actions ?", actions, multi=True)
liste = select_accounts()
g.start_time = time() # Reset timer to the start of the actions
g.start_time = time() # Reset timer to the start of the actions
for cred in liste:
g._mail = cred[0]
@ -790,7 +797,7 @@ def CustomStart():
if "tout" in Actions:
daily_routine(True)
if "daily" in Actions:
#input("0")
# input("0")
try:
all_cards()
except Exception as e:
@ -806,9 +813,9 @@ def CustomStart():
except Exception as e:
log_error(e)
if "fidelity" in Actions:
try :
try:
fidelity()
except Exception as e :
except Exception as e:
log_error(e)
if "dev" in Actions:
try:
@ -823,9 +830,10 @@ def CustomStart():
printf(f"CustomStart {e}")
driver.quit()
def very_custom_start(json):
global driver
display = SmartDisplay(backend="xvnc", size=(1920, 1080), rfbport=2345, color_depth=24)
display = SmartDisplay(backend="xvnc", size=(1920, 1080), rfbport=2345, color_depth=24)
display.start()
for i in range(5):
cred = g._cred[i]
@ -833,93 +841,94 @@ def very_custom_start(json):
g._password = cred[1]
start = False
for j in ["unban", "tout", "pc", "mobile", "daily"]:
try :
try:
if str(i) in json[j]:
start = True
print(f"{g._mail} : {j}")
except KeyError :
except KeyError:
pass
#print(f"none is set to \"{j}\"")
# print(f"none is set to \"{j}\"")
if start:
driver = firefox_driver()
try :
try:
if str(i) in json["unban"]:
pwd_login(driver) # TODO : define only the first part of login
pwd_login(driver) # TODO : define only the first part of login
print("\nGO TO exmaple.com TO PROCEED or wait 600 secs.")
for _ in range(600):
sleep(1)
if driver.current_url == "https://example.com/":
print("proceeding")
break
else :
else:
login(driver)
except KeyError :
except KeyError:
login(driver)
try :
try:
if str(i) in json["tout"]:
daily_routine(True)
except KeyError :
except KeyError:
pass
#print("none is set to \"tout\"")
else :
try :
# print("none is set to \"tout\"")
else:
try:
if str(i) in json["daily"]:
try:
all_cards()
except Exception as e:
log_error(e)
except KeyError :
except KeyError:
pass
#print("none is set to \"daily\"")
try :
# print("none is set to \"daily\"")
try:
if str(i) in json["pc"]:
try:
bing_pc_search()
except Exception as e:
log_error(e)
except KeyError :
except KeyError:
pass
#print("none is set to \"pc\"")
try :
# print("none is set to \"pc\"")
try:
if str(i) in json["mobile"]:
try:
bing_mobile_search()
except Exception as e:
log_error(e)
except KeyError :
except KeyError:
pass
#print("none is set to \"mobile\"")
# print("none is set to \"mobile\"")
try:
log_points(g._mail)
except Exception as e:
printf(f"CustomStart {e}")
driver.close()
display.stop()
if g.very_custom :
if g.very_custom:
dict_data = json.loads(g.very_custom.replace("'", "\""))
very_custom_start(dict_data)
else :
if g.vnc_enabled or g.dev:
display = SmartDisplay(backend="xvnc", size=(1920, 1080), rfbport=g.vnc_port, color_depth=24)
else :
display = SmartDisplay(size=(1920, 1080))
else:
if g.vnc_enabled or g.dev:
display = SmartDisplay(backend="xvnc", size=(1920, 1080), rfbport=g.vnc_port, color_depth=24)
else:
display = SmartDisplay(size=(1920, 1080))
display.start()
#webhookFailure.send(f"Starting on this config", username="Check de lancement", avatar_url="https://cdn-icons-png.flaticon.com/512/1688/1688988.png")
# webhookFailure.send(f"Starting on this config", username="Check de lancement", avatar_url="https://cdn-icons-png.flaticon.com/512/1688/1688988.png")
if g.dev :
if g.dev:
driver = firefox_driver()
#input("kill ?")
# input("kill ?")
driver.quit()
elif g.custom_start:
CustomStart()
elif g.unban:
g._mail, g._password = select_accounts(False)[0]
g._mail, g._password = select_accounts(False)[0]
driver = firefox_driver()
try :
try:
login(driver)
except Banned:
unban()
@ -927,7 +936,8 @@ else :
else:
if g.update_version != "None":
if g.discord_enabled_error:
webhookFailure.send(f"Updated to {g.update_version}", username="UPDATE", avatar_url="https://cdn-icons-png.flaticon.com/512/1688/1688988.png")
webhookFailure.send(f"Updated to {g.update_version}", username="UPDATE",
avatar_url="https://cdn-icons-png.flaticon.com/512/1688/1688988.png")
for cred in g._cred:
if cred[0] != "":
g._mail = cred[0]
@ -941,7 +951,7 @@ else :
driver.implicitly_wait(3)
try:
attente = uniform(1200, 3600)
printf(f"Attente de {round(attente/60)} min avant de démarrer")
printf(f"Attente de {round(attente / 60)} min avant de démarrer")
daily_routine()
driver.quit()
custom_sleep(attente)

83
V7/V7.py Normal file
View File

@ -0,0 +1,83 @@
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
"""

10
V7/actions/checks.py Normal file
View File

@ -0,0 +1,10 @@
from playwright.sync_api import Playwright, sync_playwright, expect, Page
from playwright_stealth import stealth_sync
from logging import *
def check_logged_in(page: Page):
if "pas connecté à Microsoft Rewards" in page.content():
page.locator('css=[onclick="setsrchusr()"]').click()
page.wait_for_load_state('load')
info('Fixed logging in in card.')

30
V7/actions/login.py Normal file
View File

@ -0,0 +1,30 @@
from playwright.sync_api import Playwright, sync_playwright, expect, Page
from logging import *
def login(page: Page, mail: str, pwd: str) -> None:
page.goto("https://rewards.bing.com")
page.wait_for_load_state('load')
if page.url == "https://rewards.bing.com/":
info("Logged in via cookies")
return
else:
info("logging in")
page.get_by_placeholder("Email, phone, or Skype").click()
page.get_by_placeholder("Email, phone, or Skype").fill(mail)
page.get_by_placeholder("Email, phone, or Skype").press("Enter")
page.get_by_placeholder("Password").click()
page.get_by_placeholder("Password").fill(pwd)
page.get_by_placeholder("Password").press("Enter")
page.get_by_label("Don't show this again").check()
page.get_by_role("button", name="Yes").click()
page.wait_for_url("https://rewards.bing.com/")
page.wait_for_load_state('load')
page.goto("https://bing.com")
page.get_by_role("link", name="Sign in").click()
page.get_by_role("link", name="Accept").click()
page.wait_for_load_state('load')
page.wait_for_timeout(3000)
page.goto("https://rewards.bing.com")
page.wait_for_load_state('load')
info("Logged in via password.")

115
V7/actions/quiz.py Normal file
View File

@ -0,0 +1,115 @@
from random import choice, shuffle
from playwright.sync_api import Playwright, sync_playwright, expect, Page
from playwright_stealth import stealth_sync
from logging import *
from re import findall, search
from actions.checks import check_logged_in
def play(page: Page):
check_logged_in(page)
quiz_type = detect_quiz_type(page)
match quiz_type:
case 8 | 9:
info('Detected quiz_8.')
play_quiz_8(page)
case 5 | 4:
info('Detected quiz_4.')
play_quiz_4(page)
case 3 | 2:
info('Detected quiz_2.')
play_quiz_2(page)
case 1:
info('Detected poll.')
play_poll(page)
case 0:
info('Detected empty page.')
def detect_quiz_type(page: Page) -> int:
info("Detecting quiz type.")
if "bt_PollRadio" in page.content():
return 1
elif "rqQuestionState" in page.content():
# The quiz is already started
return page.content().count("rqAnswerOption") - 1
else:
try:
# RGPD
selector = page.locator("rqStartQuiz")
expect(selector).to_be_visible(timeout=10_000)
selector.click()
return page.content().count("rqAnswerOption") - 1
except AssertionError as e:
return 0
def play_quiz_8(page: Page):
info("Playing quiz 8.")
num_question = len(findall("<span id=\"rqQuestionState.\" class=\"emptyCircle\"></span>", page.content())) + 1
info(f"Looping on {num_question} questions.")
counter = 0
# rgpd_popup(driver)
for _ in range(num_question):
correct_answers = []
for i in range(1, 9):
element = page.locator(f'#rqAnswerOption{i - 1}')
# todo can probably be optimised using filter and has_text
if 'iscorrectoption="True"' in element.evaluate("el => el.outerHTML"):
correct_answers.append(f'rqAnswerOption{i - 1}')
shuffle(correct_answers)
for answer_id in correct_answers:
page.locator(answer_id).click()
page.wait_for_timeout(1000)
page.wait_for_timeout(3000) # todo check if there is a better method than hardcoded timout
def play_quiz_4(page: Page):
info("Playing quiz 4.")
num_question = len(findall("<span id=\"rqQuestionState.\" class=\"emptyCircle\"></span>", page.content())) + 1
info(f"Looping on {num_question} questions.")
for i in range(num_question):
txt = page.content()
answer_option = search('correctAnswer":"([^"]+)', txt)[1]
answer_option = answer_option.replace("\\u0027", "'") # replace Unicode weird symbols
page.locator(f'css=[data-option="{answer_option}"]').click()
info(f'Validated answer n°{i + 1}.')
page.wait_for_load_state('load')
debug(f'Next page loaded.')
info("Quiz 4 successful.")
def play_quiz_2(page: Page):
info("Playing quiz 2.")
for j in range(10): # todo de-hardcode the value
js_function = """
function get_correct_answer(){
function br(n) { for (var r, t = 0, i = 0; i < n.length; i++)t += n.charCodeAt(i); return r = parseInt(_G.IG.substr(_G.IG.length - 2), 16), t += r, t.toString() } // Ms check function
function namedRAValue() { //allow calls to getRAvalue
return _w.getRAValue()
};
if (br(document.getElementById("rqAnswerOption0").attributes["data-option"].value) == namedRAValue()){
return(0);
}
else {
return(1);
}
};
return(get_correct_answer())
"""
correct_answer_value = page.evaluate(js_function)
page.locator(f"#rqAnswerOption{correct_answer_value}").click()
page.wait_for_timeout(2000)
info("Quiz 2 successful.")
def play_poll(page: Page):
info("Playing poll.")
answer_elem = page.locator(f"#btoption{choice([0, 1])}")
answer_elem.click()
info("Poll successful.")

23
V7/actions/websearch.py Normal file
View File

@ -0,0 +1,23 @@
from random import choice
from playwright.sync_api import sync_playwright, expect, Page
from playwright_stealth import stealth_sync
h = open("../user_data/french", "r", encoding="utf-8")
lines = h.readlines()
if len(lines) < 3:
Liste_de_mot = list(lines[0].split(","))
else:
Liste_de_mot = [x.replace('\n', "") for x in lines]
h.close()
def pc_search(page: Page) -> None:
mot = choice(Liste_de_mot).replace(" ", "+")
page.goto(f"https://www.bing.com/search?q={mot}")
for _ in range(35): # todo de-hardcode this variable
word = choice(Liste_de_mot)
page.get_by_label("Enter your search here -").click()
page.get_by_label("Enter your search here -").fill(word)
page.get_by_label("Enter your search here -").press("Enter")

27
V7/logger.py Normal file
View File

@ -0,0 +1,27 @@
from playwright.sync_api import Page
from discord import Colour, Embed, File, RequestsWebhookAdapter, Webhook
class Logger:
def __init__(self, link):
self.wh = Webhook.from_url(link, adapter=RequestsWebhookAdapter())
def error(self, page: Page, error: str):
with open("page.html", "w") as f:
try:
f.write(page.content())
except Exception as e:
f.write(f"the driver has closed or crashed. Can't access page content\n{e}")
embed = Embed(
title="An Error has occurred",
description=str(error),
colour=Colour.red(),
)
try:
page.screenshot(path="screenshot.png")
except Exception as e:
with open("screenshot.png", "w") as f:
f.write(f"Can't take screenshot\n{e}")
file = File("screenshot.png")
embed.set_image(url="attachment://screenshot.png")
self.wh.send(embed=embed, username="error", file=file)

345731
user_data/french Normal file

File diff suppressed because it is too large Load Diff