forked from piair/MsRewards-Reborn
bump version.
This commit is contained in:
parent
9857607eb3
commit
da6ca1cdfc
62
V6.py
62
V6.py
@ -1,15 +1,13 @@
|
||||
#!/usr/bin/python3.10
|
||||
from modules.Classes.DiscordLogger import DiscordLogger
|
||||
from modules.config import *
|
||||
from modules.error import *
|
||||
from modules.driver_tools import *
|
||||
from modules.cards import *
|
||||
import modules.globals as g
|
||||
|
||||
from modules.Classes.Config import Config
|
||||
from modules.Classes.DiscordLogger import DiscordLogger
|
||||
from modules.Classes.UserCredentials import UserCredentials
|
||||
from modules.Tools.logger import warning, info, debug, error, critical
|
||||
from modules.Tools.tools import format_error
|
||||
from modules.cards import *
|
||||
from modules.config import *
|
||||
from modules.db import add_to_database
|
||||
from modules.driver_tools import *
|
||||
from modules.error import *
|
||||
|
||||
|
||||
# create a webdriver
|
||||
@ -30,8 +28,8 @@ def create_driver(mobile=False):
|
||||
else:
|
||||
chrome_options.add_argument(f"--user-agent={PC_USER_AGENT}")
|
||||
# disabled as it may cause detection
|
||||
if g.proxy_enabled:
|
||||
chrome_options.add_argument(f'--proxy-server={g.proxy_address}:{g.proxy_port}')
|
||||
if config.proxy.is_enabled():
|
||||
chrome_options.add_argument(f'--proxy-server={config.proxy.ip}:{config.proxy.port}')
|
||||
driver = uc.Chrome(options=chrome_options)
|
||||
set_language(driver)
|
||||
return driver
|
||||
@ -129,7 +127,8 @@ def play_quiz4(override: int = None):
|
||||
if not override:
|
||||
try: # fidelity quiz are much longer than usual ones
|
||||
override = int(findall('rqQuestionState([\d]{1,2})"', driver.page_source)[-1])
|
||||
except:
|
||||
except Exception as err:
|
||||
debug(err)
|
||||
override = 3
|
||||
debug(f"Override : {override}")
|
||||
|
||||
@ -191,15 +190,15 @@ def all_cards():
|
||||
log_error("Less than 10 cards. Most likely an error with login.")
|
||||
return ("PAS ASSEZ DE CARTES")
|
||||
if (len(liste) < 20): # most likely not in france
|
||||
printf("moins de 20 cartes. Probablement pas en France.")
|
||||
error("moins de 20 cartes. Probablement pas en France.")
|
||||
for i in range(len(liste)):
|
||||
printf(f"carte {i}")
|
||||
debug(f"carte {i}")
|
||||
try:
|
||||
checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML"))
|
||||
except StaleElementReferenceException:
|
||||
driver.refresh()
|
||||
liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
|
||||
printf(f"staled, {len(liste)}")
|
||||
warning(f"staled, {len(liste)}")
|
||||
checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML"))
|
||||
except IndexError:
|
||||
driver.get("https://rewards.bing.com")
|
||||
@ -210,24 +209,20 @@ def all_cards():
|
||||
except IndexError:
|
||||
if i == len(liste) & i > 15:
|
||||
checked = False
|
||||
# input("2")
|
||||
if checked:
|
||||
custom_sleep(1.5)
|
||||
driver.execute_script("arguments[0].scrollIntoView();", liste[i])
|
||||
custom_sleep(1.5)
|
||||
# input("3")
|
||||
liste[i].click()
|
||||
# input("4")
|
||||
if len(driver.window_handles) > 1:
|
||||
driver.switch_to.window(driver.window_handles[1])
|
||||
# input("5")
|
||||
try_play(driver.title)
|
||||
close_tab(driver.window_handles[1])
|
||||
try:
|
||||
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.")
|
||||
warning(f"carte {i} not okay. Retrying.")
|
||||
try:
|
||||
liste[i].click()
|
||||
except:
|
||||
@ -259,7 +254,7 @@ def all_cards():
|
||||
try:
|
||||
welcome_tour(liste[i], driver)
|
||||
except Exception as e:
|
||||
printf("no new windows" + format_error(e))
|
||||
error("no new windows" + format_error(e))
|
||||
driver.get("https://rewards.bing.com")
|
||||
custom_sleep(3)
|
||||
|
||||
@ -282,10 +277,8 @@ def promo():
|
||||
try:
|
||||
elm.click()
|
||||
except Exception as e:
|
||||
# log_error(e, driver)
|
||||
driver.execute_script("arguments[0].click();", elm)
|
||||
# log_error(e, driver)
|
||||
printf(f"that should't be there (promo), but the workarround seemed to work {e}")
|
||||
warning(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])
|
||||
@ -360,7 +353,7 @@ def try_play(nom="inconnu"):
|
||||
play(answer_number)
|
||||
|
||||
else:
|
||||
printf(f"Nothing to do on page `{nom}`")
|
||||
info(f"Nothing to do on page `{nom}`")
|
||||
custom_sleep(uniform(3, 5))
|
||||
|
||||
|
||||
@ -476,6 +469,7 @@ def bing_pc_search(override=randint(35, 40)):
|
||||
def log_points():
|
||||
driver = config.WebDriver.driver
|
||||
account = config.UserCredentials.get_mail()
|
||||
|
||||
def get_points():
|
||||
driver.get("https://rewards.bing.com")
|
||||
custom_sleep(1)
|
||||
@ -483,7 +477,8 @@ def log_points():
|
||||
try:
|
||||
point = search('availablePoints\":([\d]+)', driver.page_source)[1]
|
||||
except Exception as e:
|
||||
log_error(f"Dev error, checking why it doesn't work (waited a bit, is this still white ?) {format_error(e)}")
|
||||
log_error(
|
||||
f"Dev error, checking why it doesn't work (waited a bit, is this still white ?) {format_error(e)}")
|
||||
error("Can't get points.")
|
||||
return -1
|
||||
return point
|
||||
@ -501,6 +496,7 @@ def log_points():
|
||||
# todo: refactor and check if it works at all
|
||||
def fidelity():
|
||||
driver = config.WebDriver.driver
|
||||
|
||||
def sub_fidelity():
|
||||
try:
|
||||
wait_until_visible(By.CSS_SELECTOR, 'div[class="pull-left spacer-48-bottom punchcard-row"]', browser=driver)
|
||||
@ -536,11 +532,11 @@ def fidelity():
|
||||
custom_sleep(uniform(3, 5))
|
||||
try:
|
||||
close_tab(driver.window_handles[2], 1)
|
||||
except Exception as e:
|
||||
printf(e)
|
||||
printf("fidelity - done")
|
||||
except Exception as e:
|
||||
log_error(e)
|
||||
except Exception as err:
|
||||
error(err)
|
||||
info("fidelity - done")
|
||||
except Exception as err:
|
||||
log_error(err)
|
||||
|
||||
if driver.current_url != "https://rewards.bing.com":
|
||||
driver.get("https://rewards.bing.com")
|
||||
@ -549,8 +545,8 @@ def fidelity():
|
||||
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")
|
||||
error(f"erreur lors du click de pause: probablement pas de cartes {e}")
|
||||
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"]')
|
||||
@ -722,7 +718,7 @@ def json_start(json_entry, cred: UserCredentials):
|
||||
try:
|
||||
log_points()
|
||||
except Exception as e:
|
||||
printf(f"CustomStart {e}")
|
||||
error(f"CustomStart {e}")
|
||||
driver.close()
|
||||
cred.next_account()
|
||||
config.display.stop()
|
||||
|
Loading…
Reference in New Issue
Block a user