From ed1e91b304d05904fb56b201600ae832055b7809 Mon Sep 17 00:00:00 2001 From: piair Date: Tue, 25 Apr 2023 21:56:29 +0200 Subject: [PATCH] ptite update --- V5.py | 48 +++++++++++++++++----------- manual_claim.py | 69 ----------------------------------------- modules/cards.py | 8 +++++ modules/config.py | 10 ++++++ modules/driver_tools.py | 16 ++++++++-- modules/globals.py | 4 ++- modules/imports.py | 3 +- modules/tools.py | 9 +++--- version | 2 +- 9 files changed, 72 insertions(+), 97 deletions(-) delete mode 100644 manual_claim.py diff --git a/V5.py b/V5.py index 3dba3d4..cc00a4f 100755 --- a/V5.py +++ b/V5.py @@ -212,16 +212,24 @@ def do_poll(): def all_cards(): 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) + if "welcometour" in driver.current_url: + welcome_tour_NO(driver) try : promo() except Exception as e: printf("no promo card") - + if(len(liste) < 10): + log_error("moins de 10 cartes", driver) + if (len(liste) < 20): + if not g.norvege : + g.norvege = True + printf("moins de 20 cartes, disabling fidelity") + g.fidelity_link = "Disabled because norway" + log_error("Verifying if Norway", driver, True) for i in range(len(liste)): - if(len(liste) < 20): - log_error("moins de 20 cartes", driver) printf(f"carte {i}") try : checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML")) @@ -258,8 +266,8 @@ def all_cards(): try : welcome_tour(liste[i], driver) except Exception as e: - print(format_error(e)) - log_error("no new windows", driver) + printf("no new windows" + format_error(e)) + driver.get("https://rewards.bing.com") custom_sleep(3) @@ -382,7 +390,12 @@ def cookie_login(ldriver): except FileNotFoundError : printf("No cookies file Found.") return(False) - ldriver.refresh() + try : + ldriver.refresh() + except Exception as e: + printf(format_error(e)) + printf("FIX YOUR SITE MS.......") + return(True) @@ -402,18 +415,18 @@ def login_part_2(ldriver, cookies = False): except Exception as e: pass wait_until_visible(By.CSS_SELECTOR, '[data-bi-id="sh-sharedshell-home"]', 20, ldriver) - ldriver.get("https://www.bing.com") + ldriver.get("https://www.bing.com/?setlang=fr&cc=fr&cc=FR") rgpd_popup(ldriver) ldriver.refresh() 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("Error during login. Trying to refresh") - ldriver.refresh() - return(wait_until_visible(By.CSS_SELECTOR, '[data-bi-id="sh-sharedshell-home"]', 30, 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("Error during login. Trying to refresh") + # ldriver.refresh() + # return(wait_until_visible(By.CSS_SELECTOR, '[data-bi-id="sh-sharedshell-home"]', 30, ldriver)) + # useless ? # login() tries to login to your Microsoft account. # it uses global variable g._mail and g._password to login @@ -659,7 +672,7 @@ def daily_routine(custom = False): if not custom: # custom already login login(driver) except Banned : - log_error("THIS ACCOUNT IS BANNED. FIX THIS ISSUE WITH -U") + log_error("This account is locked. Fix that. (-U ?)", driver) return() try: @@ -676,13 +689,12 @@ def daily_routine(custom = False): bing_pc_search() except Exception as e: log_error(e) - + try: bing_mobile_search() except Exception as e: log_error(e) - try: log_points(g._mail) except Exception as e: diff --git a/manual_claim.py b/manual_claim.py deleted file mode 100644 index 9211ba0..0000000 --- a/manual_claim.py +++ /dev/null @@ -1,69 +0,0 @@ -from easyprocess import EasyProcess -from pyvirtualdisplay import Display -from modules.config import * -from selenium import webdriver -from selenium.common import exceptions -from selenium.webdriver.common.by import By -from selenium.webdriver.common.keys import Keys -from selenium.webdriver.firefox.options import Options -from selenium.webdriver.support.ui import WebDriverWait -from selenium.webdriver.support import expected_conditions as EC -from selenium.webdriver.support.ui import Select - - -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", - } - -def firefox_driver(mobile=False, Headless=False): - PC_USER_AGENT = ( - "Mozilla/5.0 (Windows NT 10.0; Win64; x64)" - "AppleWebKit/537.36 (KHTML, like Gecko)" - "Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.56") - MOBILE_USER_AGENT = ( - "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" - ) - - options = Options() - options.set_preference('intl.accept_languages', 'fr-FR, fr') - if proxy_enabled : - setup_proxy(proxy_address,proxy_port, options) - options.set_preference("browser.link.open_newwindow", 3) - if FAST : - 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 : - options.set_preference("general.useragent.override", MOBILE_USER_AGENT) - 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) - return(driver) - -def select_accounts(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 - emails_selected = enquiries.choose(f"quel{'s' if multiple else ''} compte{'s' if multiple else ''} ?", emails, multi=multiple) - return([x for x in Credentials if x[0] in emails_selected]) - - - -with Display(backend="xvnc", size=(2000, 1000), rfbport=5904) as disp: - _mail, _password = select_accounts(False)[0] - driver = firefox_driver() - print(f"connect via VNC to port 5904. \nID: {_mail}\npwd : {_password}") - i = input('stop ? ') - driver.close() diff --git a/modules/cards.py b/modules/cards.py index d280ae7..a05c665 100644 --- a/modules/cards.py +++ b/modules/cards.py @@ -18,6 +18,14 @@ def welcome_tour(elm, driver): sleep(5) driver.find_element(By.CSS_SELECTOR, '[class="c-glyph glyph-cancel"]').click() +def welcome_tour_NO(driver): + try : + 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="c-glyph glyph-cancel"]').click() + sleep(5) + def spotify(driver): sleep(5) diff --git a/modules/config.py b/modules/config.py index 6f46f3c..23ff192 100644 --- a/modules/config.py +++ b/modules/config.py @@ -69,12 +69,22 @@ parser.add_argument( dest="update_version", default="None" ) + +parser.add_argument( + "--dev", + help="dev option", + dest="dev", + action="store_true" +) + + args = parser.parse_args() g.custom_start = args.override g.unban = args.unban g.log = args.log g.full_log = args.fulllog +g.dev = args.dev if g.custom_start : g.log = True diff --git a/modules/driver_tools.py b/modules/driver_tools.py index 87bfc9e..85cc4e1 100644 --- a/modules/driver_tools.py +++ b/modules/driver_tools.py @@ -21,11 +21,23 @@ def rgpd_popup(driver) -> None: # save webdriver cookies def save_cookies(driver): - pickle.dump(driver.get_cookies(), open(f"{'/'.join(__file__.split('/')[:-2])}/user_data/cookies/{g._mail}.pkl", "wb")) + if g.dev: + f = open(f"{'/'.join(__file__.split('/')[:-2])}/user_data/cookies/{g._mail}_unsafe.pkl", "w") + for i in driver.get_cookies(): + f.write(str(i) + "\n") + f.close() + else : + pickle.dump(driver.get_cookies(), open(f"{'/'.join(__file__.split('/')[:-2])}/user_data/cookies/{g._mail}.pkl", "wb")) # load cookies previously saved to the driver def load_cookies(driver): - cookies = pickle.load(open(f"{'/'.join(__file__.split('/')[:-2])}/user_data/cookies/{g._mail}.pkl", "rb")) + if g.dev: + f = open(f"{'/'.join(__file__.split('/')[:-2])}/user_data/cookies/{g._mail}_unsafe.pkl", "r") + lines = f.readlines() + f.close() + cookies = [literal_eval(x) for x in lines] + else : + cookies = pickle.load(open(f"{'/'.join(__file__.split('/')[:-2])}/user_data/cookies/{g._mail}.pkl", "rb")) for cookie in cookies: driver.add_cookie(cookie) diff --git a/modules/globals.py b/modules/globals.py index 92c4f2a..bca7c85 100644 --- a/modules/globals.py +++ b/modules/globals.py @@ -31,4 +31,6 @@ sql_enabled = False sql_usr = "None" sql_pwd = "azerty" sql_host = "https://example.com" -sql_database = "MsRewards" \ No newline at end of file +sql_database = "MsRewards" +dev = False +norvege = False \ No newline at end of file diff --git a/modules/imports.py b/modules/imports.py index a102b71..79433f9 100644 --- a/modules/imports.py +++ b/modules/imports.py @@ -26,7 +26,8 @@ from selenium.webdriver.common.keys import Keys from selenium.webdriver.firefox.options import Options from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import Select, WebDriverWait +from ast import literal_eval try: import enquiries except: - system("") # enable colors in windows cmd \ No newline at end of file + system("") # enable colors in windows cmd diff --git a/modules/tools.py b/modules/tools.py index a30f645..45e63ef 100644 --- a/modules/tools.py +++ b/modules/tools.py @@ -1,5 +1,6 @@ from modules.imports import * from modules.config import * +from modules.db import * import modules.globals as g # add the time arround the text given in [text]& def Timer(text: str) -> str: @@ -64,13 +65,11 @@ def progressBar(current, total=30, barLength=20, name="Progress"): def save_points_from_file(file): with open(file) as f: - reader = csv.reader(f) - points_list = list(reader) - + read = reader(f) + points_list = list(read) for item in points_list: compte, points = item[0], item[1] - add_to_database(compte, points, sql_host,sql_usr,sql_pwd,sql_database, save_if_fail=False) - + add_to_database(compte, points, g.sql_host,g.sql_usr,g.sql_pwd,g.sql_database, save_if_fail=False) with open(file, "w") as f: f.write("") diff --git a/version b/version index b9260c7..339cbf2 100644 --- a/version +++ b/version @@ -1 +1 @@ -v5.9.4 +v5.10.0