MsRewards/V4.py

917 lines
32 KiB
Python
Raw Normal View History

2022-03-28 18:31:55 +02:00
#!/usr/bin/python3.10
2022-02-17 12:19:47 +01:00
import asyncio
from csv import reader
2022-06-23 13:26:31 +02:00
from os import sys, system, path
2022-02-17 12:19:47 +01:00
from random import choice, randint, shuffle, uniform
from re import findall, search
2021-12-23 16:34:32 +01:00
from sys import platform
from time import sleep
2022-04-10 18:43:33 +02:00
from requests import get
2021-12-22 14:01:58 +01:00
from selenium import webdriver
2022-02-17 12:19:47 +01:00
from selenium.common import exceptions
2021-12-22 14:01:58 +01:00
from selenium.webdriver.common.by import By
2022-02-17 12:19:47 +01:00
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.firefox.options import Options
2022-10-23 19:25:04 +02:00
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
2022-06-17 07:05:46 +02:00
from modules.db import add_to_database
from modules.config import *
from modules.tools import *
from modules.error import *
2022-04-18 09:22:00 +02:00
global driver
2022-02-15 22:40:39 +01:00
2022-10-25 19:44:33 +02:00
def printf(x):
printf2(x, _mail)
2022-10-23 19:25:04 +02:00
def WaitUntilVisible(by, id, to = 20, browser = driver):
try :
WebDriverWait(browser, to).until(EC.visibility_of_element_located((by,id)), "element not found")
except TimeoutException as e:
print(f"element not found after {to}s")
2022-05-24 22:38:23 +02:00
2022-10-11 21:14:53 +02:00
def claim_amazon():
2022-10-09 13:33:13 +02:00
try :
driver.get("https://rewards.microsoft.com/redeem/000803000031")
try :
driver.find_element(By.XPATH, "//span[contains( text( ), 'ÉCHANGER UNE RÉCOMPENSE')]").click()
except :
driver.find_element(By.XPATH, "//span[contains( text( ), 'REDEEM REWARD')]").click()
2022-10-09 13:33:13 +02:00
sleep(5)
try :
driver.find_element(By.XPATH, "//span[contains( text( ), 'CONFIRMER LA RÉCOMPENSE')]").click()
except :
2022-10-11 21:14:53 +02:00
driver.find_element(By.XPATH, "//span[contains( text( ), 'CONFIRM REWARD')]").click()
2022-10-09 13:33:13 +02:00
sleep(5)
if ("/rewards/redeem/orderhistory" in driver.page_source) :
driver.get("https://rewards.microsoft.com/redeem/orderhistory")
try :
driver.find_element(By.XPATH, "//span[contains( text( ), 'Détails de la commande')]").click()
except :
driver.find_element(By.XPATH, "//span[contains( text( ), 'Get code')]").click()
2022-10-09 13:33:13 +02:00
sleep(5)
code = driver.find_element(By.CLASS_NAME, "tango-credential-value").get_attribute('innerHTML')
lien = driver.find_elements(By.CLASS_NAME, "tango-credential-key")[1].get_attribute('innerHTML')
lien = search('\"([^\"]+)\"',lien)[1]
driver.get(lien)
sleep(10)
box = driver.find_element(By.ID, "input-45")
box.click()
box.send_keys(code)
driver.find_element(By.XPATH, "//span[contains( text( ), 'Déverrouillez votre récompense')]").click()
sleep(5)
2022-10-15 16:17:21 +02:00
#amazon = search("> ([^ ]+) <", fcode)[1]
fcode = driver.find_element(By.XPATH, "/html/body/div[1]/div[1]/main/div/div/div/div/div[1]/div/div[1]/div[2]/div[2]/div/div/div/div/div/div[2]/span").get_attribute("innerHTML")
if fcode :
webhookFailure.send(_mail +" - "+ fcode)
2022-10-20 22:15:08 +02:00
return(1)
else :
2022-10-25 10:03:24 +02:00
LogError("impossible de localiser le code ", driver, _mail)
2022-10-20 22:15:08 +02:00
return(1)
2022-10-09 13:33:13 +02:00
else :
2022-10-25 10:03:24 +02:00
LogError("la recuperation ne peux pas être automatique", driver, _mail)
2022-10-20 22:15:08 +02:00
return(0)
2022-10-09 13:33:13 +02:00
except Exception as e :
2022-10-25 10:03:24 +02:00
LogError(f'problème dans la recuperation : {str(e)}', driver, _mail)
2022-10-09 13:33:13 +02:00
def setup_proxy(ip, port) :
PROXY = f"{ip}:{port}"
webdriver.DesiredCapabilities.FIREFOX['proxy'] = {
2022-05-24 22:39:18 +02:00
"httpProxy": PROXY,
"sslProxy": PROXY,
"proxyType": "MANUAL",
}
2022-03-28 16:30:11 +02:00
def FirefoxDriver(mobile=False, Headless=Headless):
if proxy_enabled :
2022-05-24 22:18:22 +02:00
setup_proxy(proxy_address,proxy_port)
PC_USER_AGENT = (
2022-06-28 12:27:22 +02:00
"Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
"AppleWebKit/537.36 (KHTML, like Gecko)"
2022-08-30 12:00:30 +02:00
"Chrome/104.0.5112.102 Safari/537.36 Edg/104.0.1293.70"
)
MOBILE_USER_AGENT = (
2022-06-28 12:27:22 +02:00
"Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X)"
"AppleWebKit/605.1.15 (KHTML, like Gecko)"
"CriOS/103.0.5060.63 Mobile/15E148 Safari/604.1"
)
2022-08-22 11:03:20 +02:00
options = Options()
2021-12-22 14:01:58 +01:00
options.set_preference("browser.link.open_newwindow", 3)
if Headless:
2021-12-22 14:01:58 +01:00
options.add_argument("-headless")
if mobile :
options.set_preference("general.useragent.override", MOBILE_USER_AGENT)
else :
options.set_preference("general.useragent.override", PC_USER_AGENT)
2022-08-30 12:00:30 +02:00
driver = webdriver.Firefox(options=options)
driver.set_window_size(1900 + hash(_mail)%20 , 1070 + hash(_password + "salt")%10)
return driver
2021-12-22 14:01:58 +01:00
def Close(fenetre, SwitchTo=0):
2021-12-22 14:01:58 +01:00
driver.switch_to.window(fenetre)
driver.close()
driver.switch_to.window(driver.window_handles[SwitchTo])
2022-05-27 09:28:31 +02:00
#Deal with RGPD popup as well as some random popup like 'are you satisfied' one
2021-12-22 14:01:58 +01:00
def RGPD():
for i in ["bnp_btn_accept", "bnp_hfly_cta2", "bnp_hfly_close"] :
try:
2022-11-05 15:30:55 +01:00
driver.find_element(By.ID, i).click()
except:
pass
2021-12-22 14:01:58 +01:00
2021-12-23 17:36:53 +01:00
"""
2022-06-20 18:16:15 +02:00
PlayQuiz[N]([int : override]) make the quizz 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 quizz. Can be usefull in some case, where the programm crashes before finishing the quizz
"""
def PlayQuiz2(override=10):
2022-10-25 19:44:33 +02:00
printf("début de PlayQuiz2")
for j in range(override):
try:
2022-04-11 12:36:03 +02:00
RGPD()
CustomSleep(uniform(3, 5))
2021-12-22 14:01:58 +01:00
txt = driver.page_source
secret = search('IG:"([^"]+)"', txt)[1] # variable dans la page, pour calculer le offset
reponse1 = search('data-option="([^"]+)"', txt)[1]
offset = int(secret[-2:], 16) # la conversion ec decimal des deux dernier caracteres de IG
reponse = search('correctAnswer":"([0-9]+)', txt)[1]
somme = 0
2021-12-22 14:01:58 +01:00
for i in reponse1:
2021-12-22 14:01:58 +01:00
somme += ord(i)
if somme + offset == int(reponse):
elem = driver.find_element(By.ID, "rqAnswerOption0")
2021-12-22 14:01:58 +01:00
elem.click()
progressBar(j, 10, name="quiz 2")
else:
elem = driver.find_element(By.ID, "rqAnswerOption1")
2021-12-22 14:01:58 +01:00
elem.click()
progressBar(j, 10, name="quiz 2")
2021-12-22 14:01:58 +01:00
except exceptions.ElementNotInteractableException as e:
driver.execute_script("arguments[0].click();", elem)
2021-12-22 14:01:58 +01:00
except Exception as e:
2022-10-25 10:03:24 +02:00
LogError("PlayQuiz2" + str(e), driver, _mail)
2021-12-22 14:01:58 +01:00
break
2022-10-25 19:44:33 +02:00
printf("PlayQuiz2 finis")
2021-12-22 14:01:58 +01:00
2022-03-28 17:00:36 +02:00
2022-11-05 15:30:55 +01:00
def PlayQuiz8():
override = len(findall("<span id=\"rqQuestionState.\" class=\"emptyCircle\"></span>", driver.page_source))+1
2022-10-25 19:44:33 +02:00
printf(f"PlayQuiz8 : start, override : {override}")
try:
2021-12-22 14:01:58 +01:00
c = 0
2021-12-23 17:36:53 +01:00
for i in range(override):
2022-04-11 12:36:03 +02:00
RGPD()
2022-09-30 14:34:50 +02:00
CustomSleep(uniform(3, 5))
2022-11-05 15:30:55 +01:00
AnswerOptions = [ (driver.find_element(By.ID, f"rqAnswerOption{i-1}"),f'rqAnswerOption{i-1}') for i in range(1,9)]
isCorrect = [x[1] for x in AnswerOptions if 'iscorrectoption="True" ' in x[0].get_attribute("outerHTML") ]
shuffle(isCorrect)
2022-11-05 15:30:55 +01:00
for i in isCorrect:
try :
WaitUntilVisible(By.ID, i, to = 20, browser=driver)
except Exception as e:
print(e)
print("wait")
c += 1
progressBar(c, 16, name="Quiz 8 ")
try:
2021-12-24 10:56:40 +01:00
elem = driver.find_element(By.ID, i)
2021-12-22 14:01:58 +01:00
elem.click()
2022-11-05 15:30:55 +01:00
except exceptions.NoSuchElementException :
driver.refresh()
CustomSleep(10)
elem = driver.find_element(By.ID, i)
elem.click()
except ElementClickInterceptedException :
RGPD()
isCorrect.append(i)
except Exception as e:
2022-11-05 15:30:55 +01:00
LogError(f"PlayQuiz8 - 4 - {e} \n ListOfGood : {str(isCorrect)}", driver, _mail)
2022-06-09 14:19:34 +02:00
2022-10-25 19:44:33 +02:00
printf("PlayQuiz8 : fin ")
2021-12-22 14:01:58 +01:00
2022-03-28 17:00:36 +02:00
def PlayQuiz4(override=None):
2022-10-25 19:44:33 +02:00
printf("PlayQuiz4 : start")
if not override:
try: # permet de gerer les truc de fidélité, qui sont plus long
override = int(findall('rqQuestionState([\d]{1,2})"', driver.page_source)[-1])
2022-10-25 19:44:33 +02:00
printf(f"Override : {override}")
except:
override = 3
try:
2021-12-23 17:36:53 +01:00
for i in range(override):
CustomSleep(uniform(3, 5))
2021-12-22 14:01:58 +01:00
txt = driver.page_source
2022-04-11 12:36:03 +02:00
RGPD()
reponse = search('correctAnswer":"([^"]+)', txt)[1] # je suis pas sur qu'il y ait un espace
reponse = reponse.replace("\\u0027", "'") # il faut cancel l'unicode avec un double \ (on replacer les caracteres en unicode en caracteres utf-8)
2022-10-25 19:44:33 +02:00
printf(f"validation de la reponse ")
printf(f"validation de la reponse {i+1}/{override} {reponse}")
try:
elem = driver.find_element(
By.CSS_SELECTOR, f'[data-option="{reponse}"]'
)
2021-12-22 14:01:58 +01:00
elem.click()
except exceptions.ElementNotInteractableException:
driver.execute_script("arguments[0].click();", elem)
except Exception as e:
2022-10-25 10:03:24 +02:00
LogError(f"PlayQuiz4 {str(e)}", driver, _mail)
2021-12-22 14:01:58 +01:00
raise ValueError(e)
2022-10-25 19:44:33 +02:00
printf("PlayQuiz4 : end")
2021-12-22 14:01:58 +01:00
2022-08-29 10:44:57 +02:00
2022-06-21 17:22:44 +02:00
"""
2022-08-29 10:44:57 +02:00
PlayPoll() reply a random thing to poll, on of daily activities
2022-06-21 17:22:44 +02:00
"""
2021-12-22 14:01:58 +01:00
def PlayPoll():
2022-10-25 19:44:33 +02:00
printf("PlayPoll : start")
try:
try:
elem = driver.find_element(By.ID, f"btoption{choice([0,1])}")
2021-12-22 14:01:58 +01:00
elem.click()
except exceptions.ElementNotInteractableException as e:
driver.execute_script("arguments[0].click();", elem)
CustomSleep(uniform(2, 2.5))
except Exception as e:
2022-10-25 10:03:24 +02:00
LogError("PlayPoll" + str(e), driver, _mail)
2021-12-22 14:01:58 +01:00
raise ValueError(e)
2022-10-25 19:44:33 +02:00
printf("PlayPoll : end")
2021-12-22 14:01:58 +01:00
2022-03-28 17:00:36 +02:00
def AllCard(): # fonction qui clique sur les cartes
def reset(Partie2=False): # retourne sur la page de depart apres avoir finis
if len(driver.window_handles) == 1:
driver.get("https://www.bing.com/rewardsapp/flyout")
if Partie2:
driver.find_element(
By.XPATH, "/html/body/div/div/div[3]/div[2]/div[2]/div[2]/div[1]"
).click()
else:
2021-12-22 14:01:58 +01:00
driver.switch_to.window(driver.window_handles[1])
2022-10-25 19:44:33 +02:00
printf(f"fermeture : {driver.current_url}")
2021-12-22 14:01:58 +01:00
driver.close()
driver.switch_to.window(driver.window_handles[0])
2021-12-23 13:51:07 +01:00
reset(Partie2)
2021-12-22 14:01:58 +01:00
def dailyCards():
try:
2021-12-22 14:01:58 +01:00
for i in range(3):
2022-09-30 14:34:50 +02:00
CustomSleep(uniform(3, 5))
try:
2022-10-25 19:44:33 +02:00
printf("dailycards - show pannels")
2022-03-28 16:30:11 +02:00
titre = "erreur"
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]",
).click()
2022-02-18 18:33:32 +01:00
sleep(1)
titre = driver.title
TryPlay(titre)
sleep(1)
reset()
2022-10-25 19:44:33 +02:00
printf(f"DailyCard {titre} ok ")
except Exception as e:
2022-10-25 19:44:33 +02:00
printf(f"Allcard card {titre} error ({e})")
except Exception as e:
2022-10-25 10:03:24 +02:00
LogError(f"Dailycards {e}", driver, _mail)
try:
2022-04-07 13:43:39 +02:00
dailyCards()
except Exception as e:
2022-10-25 19:44:33 +02:00
printf(f"erreur dans les quetes de la semaine {e}")
def weekly_cards():
try:
driver.find_element(
By.XPATH, "/html/body/div/div/div[3]/div[2]/div[2]/div[2]/div[1]"
).click() # declenche la premiere partie ?
except:
2021-12-22 14:01:58 +01:00
reset()
try:
driver.find_element(
By.XPATH, "/html/body/div/div/div[3]/div[2]/div[2]/div[2]/div[1]"
).click() # declenche la deuxieme partie ?
except:
2021-12-22 14:01:58 +01:00
pass
2022-02-18 13:10:46 +01:00
for i in range(20):
2022-10-25 19:44:33 +02:00
printf("début de l'une des cartes")
driver.find_element(
By.XPATH,
"/html/body/div/div/div[3]/div[2]/div[2]/div[3]/div/div[1]/a/div/div[2]",
).click()
2022-10-25 19:44:33 +02:00
printf("carte cliquée")
2021-12-22 14:01:58 +01:00
driver.switch_to.window(driver.window_handles[len(driver.window_handles) - 1])
sleep(1)
2022-02-18 13:10:46 +01:00
titre = driver.title
print(f"carte {titre} en cours")
2021-12-23 13:51:07 +01:00
TryPlay(titre)
2021-12-22 14:01:58 +01:00
reset(True)
sleep(1)
try:
link = findall('href="([^<]+)" title=""', driver.page_source)[
3
] # verifie si on a toujours des cartes
except:
2021-12-22 14:01:58 +01:00
break
2022-06-02 12:39:30 +02:00
for i in range(2): # don't seem useful for fixing error
try :
weekly_cards()
2022-05-19 10:40:50 +02:00
break
except Exception as e:
2022-10-25 10:03:24 +02:00
LogError(f"weekly_cards, try n°{i+1} \n {e}", driver, _mail)
if i == 0 :
driver.refresh()
else :
2022-06-06 12:32:37 +02:00
CustomSleep(1800)
driver.refresh()
2021-12-22 14:01:58 +01:00
2022-10-09 13:33:13 +02:00
2022-06-21 17:22:44 +02:00
"""
login() tries to login to your micrososft account.
it uses global variable _mail and _password to login
"""
def login():
2022-06-09 14:19:34 +02:00
global driver
def sub_login():
2022-10-25 19:44:33 +02:00
printf("sublogin : start")
driver.get("https://www.bing.com/rewardsapp/flyout")
for i in [f'[title="Rejoindre"]', f'[title="Join now"]', f'[title="Rejoindre maintenant"]'] :
try:
driver.find_element(By.CSS_SELECTOR, i).click() # depend of the language of the page
break
except:
pass
2022-06-09 14:19:34 +02:00
WaitUntilVisible(By.ID, "i0116", browser = driver)
mail = driver.find_element(By.ID, "i0116")
2021-12-22 14:01:58 +01:00
send_keys_wait(mail, _mail)
mail.send_keys(Keys.ENTER)
WaitUntilVisible(By.ID, "i0118", browser = driver)
pwd = driver.find_element(By.ID, "i0118")
2021-12-22 14:01:58 +01:00
send_keys_wait(pwd, _password)
pwd.send_keys(Keys.ENTER)
2021-12-23 13:05:16 +01:00
CustomSleep(5)
if ('Abuse' in driver.current_url) :
LogError("account suspended", driver, _mail)
raise Banned()
for i in ["KmsiCheckboxField","iLooksGood", "idSIButton9", "iCancel"]:
try:
driver.find_element(By.ID, i).click()
except Exception as e:
pass
2022-08-22 11:03:20 +02:00
try :
elm = driver.find_element(By.TAG_NAME, "body")
elm.send_keys(Keys.ENTER)
except :
pass
2022-10-25 19:44:33 +02:00
printf("login completed")
2021-12-22 14:01:58 +01:00
RGPD()
2022-08-30 11:28:02 +02:00
CustomSleep(uniform(3,5))
driver.get("https://www.bing.com/rewardsapp/flyout")
2022-08-30 11:28:02 +02:00
CustomSleep(uniform(3,5))
2021-12-22 14:01:58 +01:00
2022-06-09 14:19:34 +02:00
for i in range(3) :
try :
sub_login()
2022-06-22 12:26:50 +02:00
return (driver.current_window_handle)
except Banned:
raise Banned()
2022-06-09 14:19:34 +02:00
except Exception as e:
2022-10-25 10:03:24 +02:00
LogError("login - 3 - " + str(e), driver, _mail)
2022-06-09 14:34:02 +02:00
driver.close()
2022-06-09 14:19:34 +02:00
CustomSleep(1200)
driver = FirefoxDriver()
2022-06-09 14:34:02 +02:00
return("STOP")
2021-12-22 14:01:58 +01:00
def BingPcSearch(override=randint(35, 40)):
driver.get(f"https://www.bing.com/search?q=test") # {choice(Liste_de_mot)}')
CustomSleep(uniform(1, 2))
2021-12-22 14:01:58 +01:00
RGPD()
send_keys_wait(
driver.find_element(By.ID, "sb_form_q"),
Keys.BACKSPACE
+ Keys.BACKSPACE
+ Keys.BACKSPACE
+ Keys.BACKSPACE
+ Keys.BACKSPACE
+ Keys.BACKSPACE,
)
2021-12-22 14:01:58 +01:00
for i in range(override):
2022-02-18 20:29:13 +01:00
mot = choice(Liste_de_mot)
try:
send_keys_wait(driver.find_element(By.ID, "sb_form_q"), mot)
driver.find_element(By.ID, "sb_form_q").send_keys(Keys.ENTER)
except Exception as e :
2022-10-25 19:44:33 +02:00
printf(e)
2021-12-22 14:01:58 +01:00
sleep(10)
2022-08-29 10:44:57 +02:00
driver.get('https://www.bing.com/search?q=pls')
sleep(3)
send_keys_wait(driver.find_element(By.ID, "sb_form_q"), mot)
driver.find_element(By.ID, "sb_form_q").send_keys(Keys.ENTER)
2021-12-22 14:01:58 +01:00
progressBar(i, override, name="PC")
2022-09-30 14:34:50 +02:00
CustomSleep(uniform(5, 20))
2021-12-22 14:01:58 +01:00
try:
driver.find_element(By.ID, "sb_form_q").clear()
except Exception as e:
2022-10-25 19:44:33 +02:00
printf(e)
try:
2022-08-29 10:44:57 +02:00
driver.get('https://www.bing.com/search?q=pls')
driver.find_element(By.ID, "sb_form_q").clear()
2021-12-23 13:05:16 +01:00
except Exception as e:
2022-10-25 10:03:24 +02:00
LogError(f"BingPcSearch - clear la barre de recherche - {e}", driver, _mail)
2021-12-22 14:01:58 +01:00
print("\n\n")
2021-12-22 14:01:58 +01:00
def unban():
driver.find_element(By.ID, "StartAction").click()
txt = driver.page_source
uuid1 = findall('wlspispHIPPhoneInput([a-z0-9]+)', txt)[0]
uuid2 = findall('wlspispHipSendCode([a-z0-9]+)', txt)[0]
uuid3 = findall('wlspispSolutionElement([a-z0-9]+)', txt)[0]
phone = input("entrez le numero de téléphone : +33")
WaitUntilVisible(By.ID, "wlspispHIPPhoneInput" + uuid1)
phone_box = driver.find_element(By.ID, "wlspispHIPPhoneInput" + uuid1)
phone_box.send_keys(phone)
WaitUntilVisible(By.ID, "wlspispHipSendCode" + uuid2)
send_link = driver.find_element(By.ID, "wlspispHipSendCode" + uuid2)
send_link.click()
WaitUntilVisible(By.ID, "wlspispSolutionElement" + uuid3)
answer_box = driver.find_element(By.ID, "wlspispSolutionElement" + uuid3)
answer = input("entrez le contenu du msg : ")
answer_box.send_keys(answer)
send_box = driver.find_element(By.ID, "ProofAction")
send_box.click()
WaitUntilVisible(By.ID, "FinishAction")
continue_box = driver.find_element(By.ID, "FinishAction")
continue_box.click()
2021-12-23 13:51:07 +01:00
def TryPlay(nom="inconnu"):
2021-12-22 14:01:58 +01:00
RGPD()
2022-10-25 19:44:33 +02:00
printf("TryPlay en cours")
def play(number, override=None):
if number == 8 or number == 9:
try:
2022-10-25 19:44:33 +02:00
printf(f"\033[96m Quiz 8 détecté sur la page {nom} \033[0m")
2022-03-28 19:20:06 +02:00
PlayQuiz8()
2022-10-25 19:44:33 +02:00
printf(f"\033[92m Quiz 8 reussit sur {nom} \033[0m")
except Exception as e:
2022-10-25 19:44:33 +02:00
printf(f"echec de PlayQuiz 8. Aborted {e} \033[0m")
2022-02-18 13:15:48 +01:00
elif number == 5 or number == 4:
try:
2022-10-25 19:44:33 +02:00
printf(f"\033[96m Quiz 4 détecté sur la page {nom} \033[0m")
2022-03-28 19:20:06 +02:00
PlayQuiz4()
2022-10-25 19:44:33 +02:00
printf(f"\033[92m Quiz 4 reussit sur {nom} \033[0m")
except Exception as e:
2022-10-25 19:44:33 +02:00
printf(f"echec de PlayQuiz 4. Aborted {e} \033[0m")
2022-02-18 13:15:48 +01:00
elif number == 3 or number == 2:
try:
2022-10-25 19:44:33 +02:00
printf(f"\033[96m Quiz 2 détecté sur la page {nom}\033[0m")
2022-03-28 19:20:06 +02:00
PlayQuiz2()
2022-10-25 19:44:33 +02:00
printf(f"\033[92m Quiz 2 reussit sur la page {nom}\033[0m")
except Exception as e:
2022-10-25 19:44:33 +02:00
printf(f"echec de PlayQuiz 2. Aborted {e}")
else:
2022-10-25 10:03:24 +02:00
LogError("probleme dans la carte : il y a un bouton play et aucun quiz detecté", driver, _mail)
try:
driver.find_element(By.ID, "rqStartQuiz").click() # start the quiz
number = driver.page_source.count("rqAnswerOption")
2021-12-23 16:34:32 +01:00
play(number)
except Exception as e:
2022-10-25 19:44:33 +02:00
# printf(e) normal error here
if "bt_PollRadio" in driver.page_source:
try:
2022-10-25 19:44:33 +02:00
printf("Poll détected")
2021-12-22 14:01:58 +01:00
RGPD()
PlayPoll()
2022-10-25 19:44:33 +02:00
printf("Poll reussit ")
except Exception as e:
2022-10-25 19:44:33 +02:00
printf(f"TryPlay - 1 - Poll aborted {e}")
elif "rqQuestionState" in driver.page_source:
try:
number = driver.page_source.count("rqAnswerOption")
restant = len(
findall('"rqQuestionState.?." class=', driver.page_source)
) - len(
findall(
'"rqQuestionState.?." class="filledCircle"', driver.page_source
)
)
2022-10-25 19:44:33 +02:00
printf(f"recovery détecté. quiz : {number}, restant : {restant +1}")
2022-06-09 14:19:34 +02:00
play(number-1, override=restant + 1)
except Exception as e:
2022-10-25 19:44:33 +02:00
printf("TryPlay - 2 - " + e)
2021-12-22 14:01:58 +01:00
elif search("([0-9]) de ([0-9]) finalisée", driver.page_source):
print("fidélité")
2021-12-22 14:01:58 +01:00
RGPD()
2022-04-10 18:43:33 +02:00
Fidelite()
else:
2022-10-25 19:44:33 +02:00
printf(f"rien à faire sur la page {nom}")
2021-12-22 14:01:58 +01:00
RGPD()
CustomSleep(uniform(3, 5))
2021-12-22 14:01:58 +01:00
def LogPoint(account="unknown"): # log des points sur discord
def get_points():
driver.get("https://www.bing.com/rewardsapp/flyout")
2022-09-23 15:13:14 +02:00
if not LINUX_HOST:
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
else:
asyncio.set_event_loop(asyncio.new_event_loop())
regex1 = '<a href="https://rewards\.bing\.com/" title="((.{1,3}),(.{1,3})) points" target="_blank"'
try:
point = search(regex1, driver.page_source)[1].replace(",", "")
except Exception as e:
elem = driver.find_element(By.CSS_SELECTOR, '[title="Microsoft Rewards"]')
elem.click()
CustomSleep(5)
driver.switch_to.window(driver.window_handles[len(driver.window_handles) - 1])
2022-10-13 07:18:08 +02:00
CustomSleep(uniform(5,7))
2022-06-09 14:34:02 +02:00
point = search('availablePoints":([\d]+)', driver.page_source)[1]
2022-05-24 22:32:38 +02:00
return(point)
2022-06-09 14:34:02 +02:00
for i in range (3):
try :
points = get_points()
break
except Exception as e:
2022-06-09 14:34:02 +02:00
CustomSleep(300)
2022-10-25 19:44:33 +02:00
printf(f"LogPoints : {e}")
2022-10-18 12:51:55 +02:00
points = None
2022-06-09 14:34:02 +02:00
if not points :
2022-10-25 10:03:24 +02:00
LogError(f"impossible d'avoir les points : {e}", driver, _mail)
CustomSleep(uniform(3, 20))
account = account.split("@")[0]
2022-02-17 13:40:37 +01:00
2022-10-11 21:40:41 +02:00
if DISCORD_ENABLED_SUCCESS:
2022-05-24 22:32:38 +02:00
2022-10-11 21:40:41 +02:00
if DISCORD_EMBED:
2022-05-24 22:32:38 +02:00
embed = discord.Embed(
2022-05-24 22:43:01 +02:00
title=f"{account} actuellement à {str(points)} points", colour=Colour.green()
2022-05-24 22:32:38 +02:00
)
embed.set_footer(text=account)
webhookSuccess.send(embed=embed)
else:
2022-05-24 22:43:01 +02:00
webhookSuccess.send(f"{account} actuellement à {str(points)} points")
2022-10-20 22:15:08 +02:00
if CLAIM_AMAZON and int(points) >= 7500:
if (claim_amazon() == 1) :
points -= 7500
2021-12-22 14:01:58 +01:00
2022-05-24 22:32:38 +02:00
if sql_enabled :
2022-09-30 14:59:54 +02:00
add_to_database(account, points, sql_host, sql_usr, sql_pwd, sql_database)
2021-12-22 14:01:58 +01:00
2022-10-09 13:33:13 +02:00
2022-05-15 10:56:29 +02:00
def Fidelite():
try:
while 1: #close all tabs
try:
2022-04-11 12:27:58 +02:00
Close(1)
except:
2022-04-11 12:27:58 +02:00
break
try :
result = get(FidelityLink) #get the url of fidelity page
except Exception as e :
2022-10-25 19:44:33 +02:00
printf(e)
2022-05-28 08:18:21 +02:00
result = False
2022-05-15 10:56:29 +02:00
if result :
lien = result.content.decode("UTF-8")
2022-10-25 19:44:33 +02:00
printf(lien)
2022-05-15 10:56:29 +02:00
if (lien.split(":")[0] == "https") or (lien.split(":")[0] == "http") :
driver.get(lien)
2022-06-09 14:36:51 +02:00
CustomSleep(5)
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 :
CustomSleep(300)
choix = driver.find_element(By.CSS_SELECTOR, 'div[class="pull-left spacer-48-bottom punchcard-row"]') # pull-left spacer-48-bottom punchcard-row? USELESS ?
nb = search("([0-9]) of ([0-9]) completed", driver.page_source)
if not nb:
nb = search("([0-9]) de ([0-9]) finalisé", driver.page_source)
for i in range(int(nb[2]) - int(nb[1])):
driver.refresh()
CustomSleep(2)
choix = driver.find_element(By.CLASS_NAME, "spacer-48-bottom")
2022-06-06 12:32:37 +02:00
try :
ButtonText = search('<span class="pull-left margin-right-15">([^<^>]+)</span>',choix.get_attribute("innerHTML"))[1]
bouton = driver.find_element(By.XPATH, f'//span[text()="{ButtonText}"]')
bouton.click()
except Exception as e1 :
try :
t = driver.find_element(By.XPATH,'/html/body/div[1]/div[2]/main/div[2]/div[2]/div[7]/div[3]/div[1]')
t.click()
except Exception as e2 :
2022-10-25 10:03:24 +02:00
LogError(f"fidélité - double erreur - e1 : {e1} - e2 {e2}", driver, _mail)
2022-06-06 12:32:37 +02:00
break
CustomSleep(uniform(3, 5))
driver.switch_to.window(driver.window_handles[1])
TryPlay(driver.title)
2022-06-06 12:32:37 +02:00
driver.get(lien) # USELESS ?
CustomSleep(uniform(3, 5))
try:
Close(driver.window_handles[1])
except Exception as e:
2022-10-25 19:44:33 +02:00
printf(e)
printf("fidelité - done")
else :
2022-10-25 19:44:33 +02:00
printf("lien invalide")
except Exception as e:
2022-10-25 10:03:24 +02:00
LogError("Fidélité" + str(e), driver, _mail)
def Mlogin(echec):
try:
MobileDriver.get("https://www.bing.com/search?q=test+speed")
MRGPD()
2022-10-25 19:44:33 +02:00
printf("début du login")
MobileDriver.find_element(By.ID, "mHamburger").click()
CustomSleep(uniform(1, 2))
MobileDriver.find_element(By.ID, "hb_s").click()
CustomSleep(uniform(1, 2))
mail = MobileDriver.find_element(By.ID, "i0116")
send_keys_wait(mail, _mail)
mail.send_keys(Keys.ENTER)
CustomSleep(uniform(7, 9))
pwd = MobileDriver.find_element(By.ID, "i0118")
send_keys_wait(pwd, _password)
pwd.send_keys(Keys.ENTER)
CustomSleep(uniform(1, 2))
try:
MobileDriver.find_element(By.ID, "KmsiCheckboxField").click()
except Exception as e:
pass
try:
MobileDriver.find_element(By.ID, "iLooksGood").click()
except Exception as e:
pass
try:
MobileDriver.find_element(By.ID, "idSIButton9").click()
except Exception as e:
pass
2022-10-25 19:44:33 +02:00
printf("fin du Mlogin")
except Exception as e:
echec += 1
if echec <= 3:
2022-10-25 19:44:33 +02:00
printf(f"echec du login sur la version mobile. on reesaye ({echec}/3), {e}")
CustomSleep(uniform(5, 10))
Mlogin(echec)
else:
LogError(
2022-10-25 10:03:24 +02:00
f"login impossible 3 fois de suite. {e}", MobileDriver, _mail
)
MobileDriver.quit()
return True
def MRGPD():
try:
MobileDriver.find_element(By.ID, "bnp_btn_accept").click()
except Exception as e:
pass
try:
MobileDriver.find_element(By.ID, "bnp_hfly_cta2").click()
except Exception as e:
pass
def Alerte():
try:
alert = MobileDriver.switch_to.alert
alert.dismiss()
except exceptions.NoAlertPresentException as e:
pass
except Exception as e:
2022-10-25 10:03:24 +02:00
LogError(f"mobile.py -> Alerte : {e}", MobileDriver, _mail)
def BingMobileSearch(override=randint(22, 25)):
global MobileDriver
MobileDriver = "unable to start"
try:
try:
MobileDriver = FirefoxDriver(mobile=True)
MobileDriver.implicitly_wait(15)
except Exception as e:
2022-10-25 10:03:24 +02:00
LogError("BingMobileSearch - 1 - echec de la creation du driver mobile", MobileDriver, _mail)
echec = 0
if not Mlogin(echec):
CustomSleep(uniform(1, 2))
MRGPD()
CustomSleep(uniform(1, 1.5))
for i in range(override): # 20
try :
mot = choice(Liste_de_mot)
send_keys_wait(MobileDriver.find_element(By.ID, "sb_form_q"), mot)
MobileDriver.find_element(By.ID, "sb_form_q").send_keys(Keys.ENTER)
progressBar(i, override, name="Mobile")
2022-10-25 19:44:33 +02:00
printf(MobileDriver.current_url)
CustomSleep(uniform(5, 20))
Alerte() # verifie si il y a des alertes (demande de positions ....)
MobileDriver.find_element(By.ID, "sb_form_q").clear()
except :
driver.refresh()
CustomSleep(30)
i -= 1
MobileDriver.quit()
except Exception as e:
2022-10-25 10:03:24 +02:00
LogError("BingMobileSearch - 4 - " + str(e), MobileDriver, _mail)
MobileDriver.quit()
2021-12-22 14:01:58 +01:00
2022-08-29 11:44:35 +02:00
def DailyRoutine(custom = False):
try :
login()
except Banned :
LogError("THIS ACCOUND IS BANNED. FIX THIS ISSUE WITH -U", driver, mail)
return()
try:
AllCard()
except Exception as e:
LogError(f"DailyRoutine - AllCard - \n{e}", driver, _mail)
try:
BingPcSearch()
except Exception as e:
LogError(f"DailyRoutine - BingPcSearch - \n{e}", driver, _mail)
try:
Fidelite()
except Exception as e:
LogError(f"DailyRoutine - Fidelité - \n{e}", driver, _mail)
try:
BingMobileSearch()
except Exception as e:
LogError(f"DailyRoutine - BingMobileSearch - \n{e}", driver, _mail)
try:
LogPoint(_mail)
except Exception as e:
LogError(f"DailyRoutine - LogPoint - \n{e}", driver, _mail)
2021-12-22 14:01:58 +01:00
2021-12-23 13:05:16 +01:00
def close():
driver.quit()
quit()
2021-12-22 14:01:58 +01:00
2022-04-11 12:30:45 +02:00
def dev():
pass
2021-12-22 14:01:58 +01:00
2022-02-14 16:48:57 +01:00
def CustomStart(Credentials):
2022-09-23 15:13:14 +02:00
if not LINUX_HOST :
2022-08-29 11:44:35 +02:00
raise NameError('You need to be on linux to do that, due to the utilisation of a module named enquieries, sorry.')
2022-02-14 16:48:57 +01:00
global driver
global _mail, _password
2022-02-14 16:48:57 +01:00
system("clear") # clear from previous command to allow a clean choice
actions = ["tout", "daily", "pc", "mobile", "LogPoint","Fidelite", "dev"]
Actions = enquiries.choose("quels Actions ?", actions, multi=True)
for _mail, _password in SelectAccount():
driver = FirefoxDriver()
2022-06-09 14:19:34 +02:00
driver.implicitly_wait(10)
2022-06-09 14:34:02 +02:00
if login() != "STOP":
if "tout" in Actions:
2022-08-29 11:44:35 +02:00
DailyRoutine(True)
2022-06-09 14:34:02 +02:00
if "daily" in Actions:
try:
AllCard()
except Exception as e:
2022-10-25 10:03:24 +02:00
LogError(f"AllCards - {e} -- override", driver, _mail)
2022-06-09 14:34:02 +02:00
if "pc" in Actions:
try:
BingPcSearch()
except Exception as e:
2022-10-25 10:03:24 +02:00
LogError(f"il y a eu une erreur dans BingPcSearch, {e} -- override", driver, _mail)
2022-06-09 14:34:02 +02:00
if "mobile" in Actions:
try:
BingMobileSearch()
except Exception as e:
2022-10-25 10:03:24 +02:00
LogError(f"BingMobileSearch - {e} -- override", driver, _mail)
2022-06-09 14:34:02 +02:00
if "Fidelite" in Actions:
try :
Fidelite()
except Exception as e :
2022-10-25 10:03:24 +02:00
LogError(f"Fidelite - {e} -- override", driver, _mail)
2022-06-09 14:34:02 +02:00
if "dev" in Actions:
try:
dev()
except Exception as e:
2022-10-25 19:44:33 +02:00
printf(e)
2022-06-09 14:34:02 +02:00
break
2022-09-30 15:05:58 +02:00
2022-09-30 15:07:34 +02:00
if not "tout" in Actions:
2022-09-30 15:05:18 +02:00
try:
LogPoint(_mail)
except Exception as e:
print("CustomStart " + str(e))
2022-02-23 19:02:24 +01:00
driver.close()
def SelectAccount(multiple = True):
system("clear") # clear from previous command to allow a clean choice
emails = [x[0] for x in Credentials] # list of all email adresses
emailsSelected = enquiries.choose("quels comptes ?", emails, multi=multiple)
return([x for x in Credentials if x[0] in emailsSelected])
2021-12-22 14:01:58 +01:00
2022-09-23 15:13:14 +02:00
if CUSTOM_START:
2022-02-14 16:48:57 +01:00
CustomStart(Credentials)
elif UNBAN:
_mail, _password = SelectAccount(False)[0]
try :
login()
raise NotBanned
except Banned :
unban()
except NotBanned :
LogError("you are not cureently banned on this account")
else:
2022-10-09 13:33:13 +02:00
for _mail, _password in Credentials:
2022-11-05 15:30:55 +01:00
#system("pkill -9 firefox")
print("\n\n")
2022-02-14 16:48:57 +01:00
print(_mail)
CustomSleep(1)
2022-10-25 19:44:33 +02:00
printf("début du driver")
driver = FirefoxDriver()
2022-10-25 19:44:33 +02:00
printf("driver demarré")
2022-04-11 12:48:22 +02:00
driver.implicitly_wait(7)
2021-12-22 14:01:58 +01:00
try:
2021-12-22 17:01:00 +01:00
DailyRoutine()
driver.quit()
2022-04-18 09:25:51 +02:00
attente = uniform(1200, 3600)
2022-10-25 19:44:33 +02:00
printf(f"finis. attente de {round(attente/60)}min")
2022-04-18 09:25:51 +02:00
CustomSleep(attente)
2022-02-23 17:33:44 +01:00
except KeyboardInterrupt:
print("canceled")
2021-12-23 13:05:16 +01:00
close()