oui
This commit is contained in:
parent
442dbb08d9
commit
87b47e97fd
|
@ -16,8 +16,8 @@ from selenium.webdriver.support.ui import WebDriverWait
|
||||||
from selenium.webdriver.support import expected_conditions as EC
|
from selenium.webdriver.support import expected_conditions as EC
|
||||||
from selenium.webdriver.support.ui import Select
|
from selenium.webdriver.support.ui import Select
|
||||||
|
|
||||||
|
from pyvirtualdisplay import Display
|
||||||
from pyvirtualdisplay.smartdisplay import SmartDisplay
|
from pyvirtualdisplay.smartdisplay import SmartDisplay
|
||||||
import undetected_chromedriver as uc
|
|
||||||
|
|
||||||
from rich.progress import BarColumn, Progress, TextColumn, Progress, TimeElapsedColumn, TaskProgressColumn, TimeRemainingColumn
|
from rich.progress import BarColumn, Progress, TextColumn, Progress, TimeElapsedColumn, TaskProgressColumn, TimeRemainingColumn
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ def wait_until_visible(search_by: str, identifier: str, timeout = 20, browser =
|
||||||
|
|
||||||
|
|
||||||
# automatically claim rewards wanted
|
# automatically claim rewards wanted
|
||||||
# currently support fnac, amazon and LOL RP
|
# currently supported : fnac, amazon and LOL RP
|
||||||
# return 1 for a success and 0 for a failure
|
# return 1 for a success and 0 for a failure
|
||||||
def claim(automatic_claim = True, reward_wanted = "amazon") -> int:
|
def claim(automatic_claim = True, reward_wanted = "amazon") -> int:
|
||||||
dic_id = {"amazon" : "000803000031", "RP" : "000403000103", "fnac" : ""}
|
dic_id = {"amazon" : "000803000031", "RP" : "000403000103", "fnac" : ""}
|
||||||
|
@ -158,35 +158,51 @@ def claim(automatic_claim = True, reward_wanted = "amazon") -> int:
|
||||||
except Exception as e :
|
except Exception as e :
|
||||||
LogError(f'Issue while claiming rewards. Check error. \n{str(e)}', driver, _mail)
|
LogError(f'Issue while claiming rewards. Check error. \n{str(e)}', driver, _mail)
|
||||||
|
|
||||||
|
def setup_proxy(ip, port, options, socks=False) :
|
||||||
|
PROXY = f"{ip}:{port}"
|
||||||
|
if socks :
|
||||||
|
options.set_preference('network.proxy.type', 1)
|
||||||
|
options.set_preference('network.proxy.socks', ip)
|
||||||
|
options.set_preference('network.proxy.socks_port', int(port))
|
||||||
|
options.set_preference("browser.link.open_newwindow", 3)
|
||||||
|
else :
|
||||||
|
webdriver.DesiredCapabilities.FIREFOX['proxy'] = {
|
||||||
|
"httpProxy": PROXY,
|
||||||
|
"sslProxy": PROXY,
|
||||||
|
"proxyType": "MANUAL",
|
||||||
|
}
|
||||||
|
|
||||||
# create a webdriver resembling
|
# create a webdriver
|
||||||
def uc_chrome_driver(mobile=False):
|
def firefox_driver(mobile=False, Headless=False):
|
||||||
PC_USER_AGENT = (
|
PC_USER_AGENT = (
|
||||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
|
||||||
f"AppleWebKit/{hash(_mail)%500}.{hash(_mail)%50}(KHTML, like Gecko)"
|
"AppleWebKit/537.36 (KHTML, like Gecko)"
|
||||||
f"Chrome/{100 + (hash(_mail)%8)}.{hash(_mail)%10}.{hash(_mail)%5000}.102 Safari/537.36 Edg/104.0.1293.70"
|
"Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.56")
|
||||||
)
|
|
||||||
MOBILE_USER_AGENT = (
|
MOBILE_USER_AGENT = (
|
||||||
"Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X)"
|
"Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X)"
|
||||||
f"AppleWebKit/{hash(_mail)%500}.{hash(_mail)%50} (KHTML, like Gecko)"
|
"AppleWebKit/605.1.15 (KHTML, like Gecko)"
|
||||||
f"CriOS/{100 + (hash(_mail)%8)}.{hash(_mail)%10}.{hash(_mail)%5000}.63 Mobile/15E148 Safari/604.1"
|
"CriOS/103.0.5060.63 Mobile/15E148 Safari/604.1"
|
||||||
)
|
)
|
||||||
chrome_options = uc.ChromeOptions()
|
|
||||||
chrome_options.add_experimental_option('prefs', {'intl.accept_languages': 'fr-FR, fr'})
|
options = Options()
|
||||||
#options.set_preference("browser.link.open_newwindow", 3) # open in new tab by default # missing on chrome
|
options.set_preference('intl.accept_languages', 'fr-FR, fr')
|
||||||
if proxy_enabled :
|
if proxy_enabled :
|
||||||
chrome_options.add_argument(f'--proxy-server={proxy_address}:{proxy_port}')
|
setup_proxy(proxy_address,proxy_port, options)
|
||||||
|
options.set_preference("browser.link.open_newwindow", 3)
|
||||||
if FAST :
|
if FAST :
|
||||||
chrome_options.add_argument('--blink-settings=imagesEnabled=false')#disable image loading. May add this without the fast option soon
|
options.set_preference("permissions.default.image", 2) #disable image loading. May add this without the fast option soon
|
||||||
|
if Headless:
|
||||||
|
options.add_argument("-headless")
|
||||||
if mobile :
|
if mobile :
|
||||||
chrome_options.add_argument(f'--user-agent={MOBILE_USER_AGENT}')
|
options.set_preference("general.useragent.override", MOBILE_USER_AGENT)
|
||||||
else :
|
else :
|
||||||
chrome_options.add_argument(f'--user-agent={PC_USER_AGENT}')
|
options.set_preference("general.useragent.override", PC_USER_AGENT)
|
||||||
driver =uc.Chrome(options=chrome_options)
|
driver = webdriver.Firefox(options=options)
|
||||||
driver.set_window_size(1800 + hash(_mail)%120 , 1000 + hash(_password + "salt")%80)
|
driver.set_window_size(1900 + hash(_mail)%20 , 1070 + hash(_password + "salt")%10)
|
||||||
return(driver)
|
return(driver)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# close the tab currently on and go back to the one first, or the one specified
|
# close the tab currently on and go back to the one first, or the one specified
|
||||||
def close_tab(tab, SwitchTo=0) -> None:
|
def close_tab(tab, SwitchTo=0) -> None:
|
||||||
driver.switch_to.window(tab)
|
driver.switch_to.window(tab)
|
||||||
|
@ -270,7 +286,6 @@ def play_quiz8(task = None):
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LogError(f"play_quiz8 - 4 - {e} \n Good answers : {' '.join(answer_id)}", driver, _mail)
|
LogError(f"play_quiz8 - 4 - {e} \n Good answers : {' '.join(answer_id)}", driver, _mail)
|
||||||
|
|
||||||
printf("play_quiz8 : fin ")
|
printf("play_quiz8 : fin ")
|
||||||
|
|
||||||
|
|
||||||
|
@ -489,17 +504,6 @@ def login():
|
||||||
def sub_login():
|
def sub_login():
|
||||||
printf("sub_login : start")
|
printf("sub_login : start")
|
||||||
driver.get("https://login.live.com")
|
driver.get("https://login.live.com")
|
||||||
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
|
|
||||||
try:
|
|
||||||
driver.find_element(By.XPATH, "/html/body/div/div/div/div/div[2]/a").click() # may need to be clicked if the language is english
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
wait_until_visible(By.ID, "i0116", browser = driver)
|
wait_until_visible(By.ID, "i0116", browser = driver)
|
||||||
mail_elem = driver.find_element(By.ID, "i0116")
|
mail_elem = driver.find_element(By.ID, "i0116")
|
||||||
send_keys_wait(mail_elem, _mail)
|
send_keys_wait(mail_elem, _mail)
|
||||||
|
@ -517,8 +521,10 @@ def login():
|
||||||
for id in ["KmsiCheckboxField","iLooksGood", "idSIButton9", "iCancel"]:
|
for id in ["KmsiCheckboxField","iLooksGood", "idSIButton9", "iCancel"]:
|
||||||
try:
|
try:
|
||||||
driver.find_element(By.ID, id).click()
|
driver.find_element(By.ID, id).click()
|
||||||
|
restart = True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try :
|
try :
|
||||||
body_elem = driver.find_element(By.TAG_NAME, "body")
|
body_elem = driver.find_element(By.TAG_NAME, "body")
|
||||||
body_elem.send_keys(Keys.ENTER)
|
body_elem.send_keys(Keys.ENTER)
|
||||||
|
@ -529,6 +535,13 @@ def login():
|
||||||
custom_sleep(uniform(3,5))
|
custom_sleep(uniform(3,5))
|
||||||
driver.get("https://www.bing.com/rewardsapp/flyout")
|
driver.get("https://www.bing.com/rewardsapp/flyout")
|
||||||
custom_sleep(uniform(3,5))
|
custom_sleep(uniform(3,5))
|
||||||
|
for i in [f'[title="Rejoindre maintenant"]', f'[title="Rejoindre"]', f'[title="Join now"]'] :
|
||||||
|
try:
|
||||||
|
driver.find_element(By.CSS_SELECTOR, i).click() # depend of the language of the page
|
||||||
|
break
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
driver.get("https://www.bing.com/rewardsapp/flyout")
|
||||||
|
|
||||||
for _ in range(3) :
|
for _ in range(3) :
|
||||||
try :
|
try :
|
||||||
|
@ -540,14 +553,14 @@ def login():
|
||||||
LogError(f"login - 3 - {e}", driver, _mail)
|
LogError(f"login - 3 - {e}", driver, _mail)
|
||||||
driver.quit()
|
driver.quit()
|
||||||
custom_sleep(1200)
|
custom_sleep(1200)
|
||||||
driver = uc_chrome_driver()
|
driver = firefox_driver()
|
||||||
return("STOP")
|
return("STOP")
|
||||||
|
|
||||||
|
|
||||||
# Makes 30 search as PC Edge
|
# Makes 30 search as PC Edge
|
||||||
def bing_pc_search(override=randint(35, 40)):
|
def bing_pc_search(override=randint(35, 40)):
|
||||||
StartTask(task["PC"])
|
StartTask(task["PC"])
|
||||||
driver.get(f"https://www.bing.com/search?q=test") # {choice(Liste_de_mot)}')
|
driver.get(f"https://www.bing.com/search?q=internet") # {choice(Liste_de_mot)}')
|
||||||
custom_sleep(uniform(1, 2))
|
custom_sleep(uniform(1, 2))
|
||||||
rgpd_popup()
|
rgpd_popup()
|
||||||
send_keys_wait(
|
send_keys_wait(
|
||||||
|
@ -576,7 +589,7 @@ def bing_pc_search(override=randint(35, 40)):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
printf(e)
|
printf(e)
|
||||||
try:
|
try:
|
||||||
driver.get('https://www.bing.com/search?q=pls')
|
driver.get('https://www.bing.com/search?q=plans')
|
||||||
driver.find_element(By.ID, "sb_form_q").clear()
|
driver.find_element(By.ID, "sb_form_q").clear()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LogError(f"bing_pc_search - clear la barre de recherche - {e}", driver, _mail)
|
LogError(f"bing_pc_search - clear la barre de recherche - {e}", driver, _mail)
|
||||||
|
@ -614,13 +627,12 @@ def unban() -> None:
|
||||||
wait_until_visible(By.ID, "FinishAction", browser=driver)
|
wait_until_visible(By.ID, "FinishAction", browser=driver)
|
||||||
end_elem = driver.find_element(By.ID, "FinishAction")
|
end_elem = driver.find_element(By.ID, "FinishAction")
|
||||||
end_elem.click()
|
end_elem.click()
|
||||||
|
|
||||||
|
|
||||||
# Sends points to database, discord and whatever
|
|
||||||
|
# Sends points to database, discord and whatever service you want
|
||||||
def log_points(account="unknown"):
|
def log_points(account="unknown"):
|
||||||
def get_points():
|
def get_points():
|
||||||
driver.get("https://www.bing.com/rewardsapp/flyout")
|
driver.get("https://www.bing.com/rewardsapp/flyout")
|
||||||
|
|
||||||
regex1 = '<a href="https://rewards\.bing\.com/" title="((.{1,3}),(.{1,3})) points" target="_blank"'
|
regex1 = '<a href="https://rewards\.bing\.com/" title="((.{1,3}),(.{1,3})) points" target="_blank"'
|
||||||
try:
|
try:
|
||||||
point = search(regex1, driver.page_source)[1].replace(",", "")
|
point = search(regex1, driver.page_source)[1].replace(",", "")
|
||||||
|
@ -791,7 +803,7 @@ def bing_mobile_search(override=randint(22, 25)):
|
||||||
mobile_driver = "unable to start"
|
mobile_driver = "unable to start"
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
mobile_driver = uc_chrome_driver(mobile=True)
|
mobile_driver = firefox_driver(mobile=True)
|
||||||
mobile_driver.implicitly_wait(15)
|
mobile_driver.implicitly_wait(15)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LogError("bing_mobile_search - 1 - failure of mobile driver creation", mobile_driver, _mail)
|
LogError("bing_mobile_search - 1 - failure of mobile driver creation", mobile_driver, _mail)
|
||||||
|
@ -886,7 +898,7 @@ def CustomStart(Credentials):
|
||||||
task = modules.progress.dico(p)
|
task = modules.progress.dico(p)
|
||||||
for _mail, _password in liste:
|
for _mail, _password in liste:
|
||||||
|
|
||||||
driver = uc_chrome_driver()
|
driver = firefox_driver()
|
||||||
driver.implicitly_wait(10)
|
driver.implicitly_wait(10)
|
||||||
|
|
||||||
if login() != "STOP":
|
if login() != "STOP":
|
||||||
|
@ -979,7 +991,11 @@ def ShowDefaultTask():
|
||||||
for i in ["PC", "Mobile"]:
|
for i in ["PC", "Mobile"]:
|
||||||
ShowTask(task[i])
|
ShowTask(task[i])
|
||||||
|
|
||||||
display = SmartDisplay(size=(2000, 1000))
|
|
||||||
|
if VNC_ENABLED :
|
||||||
|
display = Display(backend="xvnc", size=(2000, 1100), rfbport=VNC_PORT, color_depth=24)
|
||||||
|
else :
|
||||||
|
display = SmartDisplay(size=(2000, 1100))
|
||||||
display.start()
|
display.start()
|
||||||
|
|
||||||
|
|
||||||
|
@ -987,7 +1003,7 @@ if CUSTOM_START:
|
||||||
CustomStart(Credentials)
|
CustomStart(Credentials)
|
||||||
elif UNBAN:
|
elif UNBAN:
|
||||||
_mail, _password = select_accounts(False)[0]
|
_mail, _password = select_accounts(False)[0]
|
||||||
driver = uc_chrome_driver()
|
driver = firefox_driver()
|
||||||
try :
|
try :
|
||||||
login()
|
login()
|
||||||
except Banned:
|
except Banned:
|
||||||
|
@ -998,7 +1014,7 @@ elif UNBAN:
|
||||||
elif CLAIM:
|
elif CLAIM:
|
||||||
_mail, _password = select_accounts(False)[0]
|
_mail, _password = select_accounts(False)[0]
|
||||||
reward = enquiries.choose(f"quels recompense ?", ["amazon", "fnac", "RP"], multi=False)
|
reward = enquiries.choose(f"quels recompense ?", ["amazon", "fnac", "RP"], multi=False)
|
||||||
driver = uc_chrome_driver()
|
driver = firefox_driver()
|
||||||
login()
|
login()
|
||||||
claim(False, reward)
|
claim(False, reward)
|
||||||
log_points()
|
log_points()
|
||||||
|
@ -1007,7 +1023,6 @@ elif CLAIM:
|
||||||
elif POINTS_FILE != "":
|
elif POINTS_FILE != "":
|
||||||
SavePointsFromFile(POINTS_FILE)
|
SavePointsFromFile(POINTS_FILE)
|
||||||
else:
|
else:
|
||||||
|
|
||||||
with Progress(
|
with Progress(
|
||||||
TextColumn("[progress.description]{task.description}"),
|
TextColumn("[progress.description]{task.description}"),
|
||||||
BarColumn(),
|
BarColumn(),
|
||||||
|
@ -1023,7 +1038,7 @@ else:
|
||||||
print(_mail)
|
print(_mail)
|
||||||
custom_sleep(1)
|
custom_sleep(1)
|
||||||
printf("début du driver")
|
printf("début du driver")
|
||||||
driver = uc_chrome_driver()
|
driver = firefox_driver()
|
||||||
printf("driver demarré")
|
printf("driver demarré")
|
||||||
driver.implicitly_wait(7)
|
driver.implicitly_wait(7)
|
||||||
|
|
||||||
|
@ -1035,11 +1050,10 @@ else:
|
||||||
custom_sleep(attente)
|
custom_sleep(attente)
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("canceled.")
|
print("canceled. Closing driver and display.")
|
||||||
driver.quit()
|
|
||||||
display.stop()
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"error not catched. exiting. {e}")
|
print(f"error not catched. exiting. {e}")
|
||||||
|
finally :
|
||||||
driver.quit()
|
driver.quit()
|
||||||
display.stop()
|
display.stop()
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,14 @@ parser.add_argument(
|
||||||
default=""
|
default=""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"-v",
|
||||||
|
"--vnc",
|
||||||
|
help="enable VNC",
|
||||||
|
dest="vnc",
|
||||||
|
default="None"
|
||||||
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
CLAIM = args.claim
|
CLAIM = args.claim
|
||||||
CUSTOM_START = args.override
|
CUSTOM_START = args.override
|
||||||
|
@ -87,7 +95,8 @@ FULL_LOG = args.fulllog
|
||||||
FAST = args.fast
|
FAST = args.fast
|
||||||
if CUSTOM_START :
|
if CUSTOM_START :
|
||||||
LOG = True
|
LOG = True
|
||||||
|
VNC_ENABLED = args.vnc != "None"
|
||||||
|
VNC_PORT = args.vnc
|
||||||
POINTS_FILE = args.points_file
|
POINTS_FILE = args.points_file
|
||||||
|
|
||||||
# global variables used later in the code
|
# global variables used later in the code
|
||||||
|
|
Loading…
Reference in New Issue