MsRewards-Reborn/V6.py

850 lines
32 KiB
Python
Raw Normal View History

2023-01-29 00:51:30 +01:00
#!/usr/bin/python3.10
from modules.config import *
from modules.error import *
from modules.driver_tools import *
2023-04-17 22:00:46 +02:00
from modules.cards import *
2023-04-12 18:25:12 +02:00
import modules.globals as g
2023-01-29 00:51:30 +01:00
2024-02-27 00:33:48 +01:00
from modules.Classes.Config import Config
from modules.Classes.UserCredentials import UserCredentials
from modules.Tools.logger import warning, info, debug, error, critical
2023-04-12 18:25:12 +02:00
driver = g.driver
display = g.display
2023-02-08 15:14:13 +01:00
2023-03-27 22:47:29 +02:00
# create a webdriver
2024-02-27 00:33:48 +01:00
def create_driver(mobile=False):
2023-03-27 22:47:29 +02:00
PC_USER_AGENT = (
2023-06-24 16:39:42 +02:00
"Mozilla/5.0 (X11; Linux x86_64)"
2023-03-27 22:47:29 +02:00
"AppleWebKit/537.36 (KHTML, like Gecko)"
2024-02-27 00:33:48 +01:00
"Chrome/122.0.0.0 Safari/537.36 Edg/122.0.2088.46"
)
2023-03-27 22:47:29 +02:00
MOBILE_USER_AGENT = (
2024-02-27 00:33:48 +01:00
"Mozilla/5.0 (Linux; Android 7.0; Nexus 5 Build/MRA58N)"
2023-06-24 16:39:42 +02:00
"AppleWebKit/537.36 (KHTML, like Gecko)"
2024-02-27 00:33:48 +01:00
"Chrome/22 Mobile Safari/537.36"
2023-03-27 22:47:29 +02:00
)
2023-06-17 16:52:47 +02:00
chrome_options = webdriver.ChromeOptions()
2023-06-24 16:39:42 +02:00
if mobile:
chrome_options.add_argument(f"--user-agent={MOBILE_USER_AGENT}")
else:
2023-06-25 10:49:25 +02:00
chrome_options.add_argument(f"--user-agent={PC_USER_AGENT}")
2023-06-24 16:39:42 +02:00
# disabled as it may cause detection
2023-06-17 16:52:47 +02:00
if g.proxy_enabled:
2024-02-27 00:33:48 +01:00
chrome_options.add_argument(f'--proxy-server={g.proxy_address}:{g.proxy_port}')
2023-06-17 16:52:47 +02:00
driver = uc.Chrome(options=chrome_options)
2023-06-25 10:49:25 +02:00
set_language(driver)
2024-02-27 00:33:48 +01:00
return driver
2023-03-27 22:47:29 +02:00
2024-02-27 00:33:48 +01:00
def log_error(error_message, l_driver=driver, log=g.full_log):
2023-03-19 12:21:57 +01:00
global driver
if l_driver is None:
l_driver = driver
2024-02-27 00:33:48 +01:00
if type(error_message) is not str:
error_message = format_error(error_message)
error(str(error_message))
2023-04-15 11:03:47 +02:00
if g.discord_enabled_error:
2023-03-18 19:12:27 +01:00
with open("page.html", "w") as f:
try:
f.write(l_driver.page_source)
except:
2023-03-29 23:09:16 +02:00
f.write("the driver has closed or crashed. Can't access page content")
try:
2023-03-26 22:56:57 +02:00
img = display.waitgrab()
img.save("screenshot.png")
except:
l_driver.save_screenshot("screenshot.png")
2023-03-18 19:12:27 +01:00
if not log:
2023-03-27 22:47:29 +02:00
embed = Embed(
2023-03-18 19:12:27 +01:00
title="An Error has occured",
2024-02-27 00:33:48 +01:00
description=str(error_message),
2023-03-18 19:12:27 +01:00
colour=Colour.red(),
)
else:
2023-03-27 22:47:29 +02:00
embed = Embed(
2023-03-18 19:12:27 +01:00
title="Full log is enabled",
2024-02-27 00:33:48 +01:00
description=str(error_message),
2023-03-18 19:12:27 +01:00
colour=Colour.blue(),
)
2023-03-27 22:47:29 +02:00
file = File("screenshot.png")
2023-03-18 19:12:27 +01:00
embed.set_image(url="attachment://screenshot.png")
2023-04-12 18:25:12 +02:00
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)
2023-02-25 19:05:47 +01:00
2023-01-29 00:51:30 +01:00
# close the tab currently on and go back to the one first, or the one specified
2024-02-27 00:33:48 +01:00
def close_tab(tab, switch_to: int = 0) -> None:
2023-01-29 00:51:30 +01:00
driver.switch_to.window(tab)
driver.close()
2024-02-27 00:33:48 +01:00
driver.switch_to.window(driver.window_handles[switch_to])
2023-01-29 00:51:30 +01:00
# play_quiz[N]([int : override]) make the quiz with N choice each time. They usually have between 4 and 10 questions.
2024-02-27 00:48:55 +01:00
# 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
2023-01-29 00:51:30 +01:00
def play_quiz2(override=10) -> None:
2024-02-27 00:48:55 +01:00
info("Starting to play quiz 2.")
debug(f"override: {override}")
2023-01-29 00:51:30 +01:00
for j in range(override):
2024-02-27 00:48:55 +01:00
custom_sleep(uniform(3, 5))
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 = driver.execute_script(js_function)
2023-01-29 00:51:30 +01:00
try:
2023-08-13 20:37:21 +02:00
answer_elem = driver.find_element(By.ID, f"rqAnswerOption{correct_answer_value}")
answer_elem.click()
2024-02-27 00:48:55 +01:00
except exceptions.ElementNotInteractableException:
answer_elem = driver.find_element(By.ID, f"rqAnswerOption{correct_answer_value}")
2023-01-29 00:51:30 +01:00
driver.execute_script("arguments[0].click();", answer_elem)
except Exception as e:
2023-03-18 19:12:27 +01:00
log_error(e)
2023-01-29 00:51:30 +01:00
break
2024-02-27 00:48:55 +01:00
info("Quiz 2 done.")
2023-04-15 11:03:47 +02:00
custom_sleep(3)
2023-01-29 00:51:30 +01:00
2023-03-19 18:50:29 +01:00
def play_quiz8():
2024-02-27 00:48:55 +01:00
info(f"Starting Quiz 8")
override = len(findall("<span id=\"rqQuestionState.\" class=\"emptyCircle\"></span>", driver.page_source)) + 1
2024-02-27 00:48:55 +01:00
debug(f"override : {override}")
correct_answers = ["Should", "be", "reset", "before", "you", "see", "this."] # supress warning
2023-01-29 00:51:30 +01:00
try:
for _ in range(override):
2023-04-12 00:01:24 +02:00
sleep(uniform(3, 5))
2023-03-12 11:22:49 +01:00
correct_answers = []
2024-02-27 00:48:55 +01:00
for i in range(1, 9): # todo: remove this odd 1-offset
try:
element = driver.find_element(By.ID, f"rqAnswerOption{i - 1}")
2023-03-12 11:22:49 +01:00
if 'iscorrectoption="True"' in element.get_attribute("outerHTML"):
correct_answers.append(f'rqAnswerOption{i - 1}')
except Exception as e:
2024-02-27 00:48:55 +01:00
warning(f"can't find rqAnswerOption{i - 1}. Probably already clicked" + str(e))
2023-01-29 00:51:30 +01:00
shuffle(correct_answers)
for answer_id in correct_answers:
wait_until_visible(By.ID, answer_id, timeout=20, browser=driver)
2023-01-29 00:51:30 +01:00
try:
answer_elem = driver.find_element(By.ID, answer_id)
answer_elem.click()
2023-04-12 00:01:24 +02:00
sleep(1)
except exceptions.NoSuchElementException:
2023-01-29 00:51:30 +01:00
driver.refresh()
2023-04-12 00:01:24 +02:00
sleep(10)
2023-01-29 00:51:30 +01:00
answer_elem = driver.find_element(By.ID, answer_id)
answer_elem.click()
except ElementClickInterceptedException:
rgpd_popup(driver)
2023-01-29 00:51:30 +01:00
correct_answers.append(answer_id)
except Exception as e:
2023-03-18 19:12:27 +01:00
log_error(f"{format_error(e)} \n Good answers : {' '.join(correct_answers)}")
2024-02-27 00:48:55 +01:00
info("Quiz 8 done.")
2023-04-15 11:03:47 +02:00
custom_sleep(3)
2023-01-29 00:51:30 +01:00
def play_quiz4(override: int = None):
2024-02-27 00:48:55 +01:00
info(f"Starting Quiz 4")
2023-01-29 00:51:30 +01:00
if not override:
try: # fidelity quiz are much longer than usual ones
override = int(findall('rqQuestionState([\d]{1,2})"', driver.page_source)[-1])
except:
override = 3
2024-02-27 00:48:55 +01:00
debug(f"Override : {override}")
2023-01-29 00:51:30 +01:00
try:
for i in range(override):
custom_sleep(uniform(3, 5))
txt = driver.page_source
answer_option = search('correctAnswer":"([^"]+)', txt)[1]
answer_option = answer_option.replace("\\u0027", "'") # replace Unicode weird symbols
2024-02-27 00:48:55 +01:00
answer_element = driver.find_element(By.CSS_SELECTOR, f'[data-option="{answer_option}"]')
2023-01-29 00:51:30 +01:00
try:
answer_element.click()
except exceptions.ElementNotInteractableException:
driver.execute_script("arguments[0].click();", answer_element)
except Exception as e:
2023-03-18 19:12:27 +01:00
log_error(e)
2023-01-29 00:51:30 +01:00
raise ValueError(e)
2024-02-27 00:48:55 +01:00
info("Quiz 8 done.")
2023-04-15 11:03:47 +02:00
custom_sleep(3)
2023-01-29 00:51:30 +01:00
# do_poll() answer a random thing to poll, on of daily activities
def do_poll():
2024-02-27 00:48:55 +01:00
info("Starting poll")
2023-01-29 00:51:30 +01:00
try:
2024-02-27 00:48:55 +01:00
answer_elem = driver.find_element(By.ID, f"btoption{choice([0, 1])}")
2023-01-29 00:51:30 +01:00
try:
answer_elem.click()
except exceptions.ElementNotInteractableException:
driver.execute_script("arguments[0].click();", answer_elem)
custom_sleep(uniform(2, 2.5))
2024-02-27 00:48:55 +01:00
except Exception as err:
log_error(err)
raise ValueError(err)
info("Poll done.")
2023-04-15 11:03:47 +02:00
custom_sleep(3)
2023-01-29 00:51:30 +01:00
# Find each playable card and tries to click on it to earn points
# todo : refactor
2023-04-13 22:22:06 +02:00
def all_cards():
driver.get("https://rewards.bing.com")
2023-04-25 21:56:29 +02:00
wait_until_visible(By.CLASS_NAME, "c-card-content", 10, driver)
2023-04-13 22:22:06 +02:00
liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
custom_sleep(2)
try:
2023-04-13 22:22:06 +02:00
promo()
2023-01-29 00:51:30 +01:00
except Exception as e:
info("no promo card")
if (len(liste) < 10): # most likely an error during loading
2023-05-12 14:53:52 +02:00
if "suspendu" in driver.page_source:
raise Banned()
driver.refresh()
liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
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
2023-05-12 14:53:52 +02:00
printf("moins de 20 cartes. Probablement pas en France.")
2023-04-13 22:22:06 +02:00
for i in range(len(liste)):
printf(f"carte {i}")
try:
2023-04-13 22:22:06 +02:00
checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML"))
except StaleElementReferenceException:
2023-05-04 17:49:51 +02:00
driver.refresh()
2023-04-13 22:22:06 +02:00
liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
printf(f"staled, {len(liste)}")
checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML"))
2023-04-17 22:00:46 +02:00
except IndexError:
driver.get("https://rewards.bing.com")
2023-04-17 22:00:46 +02:00
custom_sleep(10)
liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
try:
checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML"))
except IndexError:
if i == len(liste) & i > 15:
2023-05-30 20:21:25 +02:00
checked = False
# input("2")
2023-04-13 22:22:06 +02:00
if checked:
custom_sleep(1.5)
2023-04-13 22:22:06 +02:00
driver.execute_script("arguments[0].scrollIntoView();", liste[i])
custom_sleep(1.5)
# input("3")
2023-04-13 22:22:06 +02:00
liste[i].click()
# input("4")
if len(driver.window_handles) > 1:
2023-04-13 22:22:06 +02:00
driver.switch_to.window(driver.window_handles[1])
# input("5")
2023-04-13 22:38:27 +02:00
try_play(driver.title)
2023-04-13 22:22:06 +02:00
close_tab(driver.window_handles[1])
try:
2023-04-13 22:22:06 +02:00
driver.refresh()
liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
if ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML")):
2023-04-13 22:22:06 +02:00
printf(f"carte {i} not okay. Retrying.")
try:
2023-05-04 17:49:51 +02:00
liste[i].click()
except:
2023-05-04 17:49:51 +02:00
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"))
2023-04-13 22:22:06 +02:00
driver.switch_to.window(driver.window_handles[1])
2023-04-13 22:38:27 +02:00
try_play(driver.title)
2023-04-13 22:22:06 +02:00
close_tab(driver.window_handles[1])
2023-05-04 17:49:51 +02:00
if ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML")):
2023-05-30 20:21:25 +02:00
driver.execute_script("arguments[0].scrollIntoView();", liste[i])
log_error(f"Card {i} Can't be completed. Why MS ?", driver)
2023-05-30 20:21:25 +02:00
liste[i].click()
driver.switch_to.window(driver.window_handles[1])
log_error(f"Cart completion - log - 2", driver)
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:
2023-06-22 22:27:41 +02:00
close_tab(driver.window_handles[1])
2023-06-21 21:24:30 +02:00
except:
pass
except:
2023-05-30 20:21:25 +02:00
driver.get("https://rewards.bing.com")
except:
2023-04-13 22:22:06 +02:00
pass
else:
try:
2023-04-17 22:00:46 +02:00
welcome_tour(liste[i], driver)
2023-04-13 22:22:06 +02:00
except Exception as e:
2023-04-25 21:56:29 +02:00
printf("no new windows" + format_error(e))
driver.get("https://rewards.bing.com")
2023-04-13 22:22:06 +02:00
custom_sleep(3)
2023-01-29 00:51:30 +01:00
2023-04-13 22:38:27 +02:00
2023-04-13 22:22:06 +02:00
def promo():
2023-05-31 10:52:45 +02:00
for i in range(5):
2023-05-30 20:21:25 +02:00
elm = driver.find_element(By.ID, "promo-item")
wait_until_visible(By.ID, "promo-item", 5, driver)
2023-04-14 10:31:12 +02:00
if not elm:
break
if i > 3:
2023-05-31 10:52:45 +02:00
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()
2023-06-22 19:20:32 +02:00
except Exception as e:
log_error(f"can't click to close : {e}")
return ()
try:
elm.click()
2023-05-30 20:21:25 +02:00
except Exception as e:
# log_error(e, driver)
driver.execute_script("arguments[0].click();", elm)
# log_error(e, driver)
2023-05-30 20:21:25 +02:00
printf(f"that should't be there (promo), but the workarround seemed to work {e}")
2023-04-13 22:22:06 +02:00
custom_sleep(3)
if len(driver.window_handles) > 1:
driver.switch_to.window(driver.window_handles[len(driver.window_handles) - 1])
2023-04-14 10:31:12 +02:00
try_play(driver.title)
2023-04-13 22:22:06 +02:00
close_tab(driver.window_handles[1])
else:
try:
2023-04-17 22:00:46 +02:00
spotify(driver)
except:
warning("no new windows")
2023-04-14 10:31:12 +02:00
driver.get("https://rewards.bing.com")
driver.refresh()
2023-04-13 22:22:06 +02:00
custom_sleep(3)
2023-01-29 00:51:30 +01:00
2023-04-17 22:00:46 +02:00
2023-01-29 00:51:30 +01:00
# Find out which type of action to do
2023-03-19 18:50:29 +01:00
def try_play(nom="inconnu"):
2023-09-25 19:19:22 +02:00
rgpd_popup(driver)
2023-01-29 00:51:30 +01:00
def play(number):
if number in [8, 9]:
2023-01-29 00:51:30 +01:00
try:
debug(f"Quiz 8 detected on `{nom}`.")
2023-03-19 18:50:29 +01:00
play_quiz8()
except Exception as err:
error(f"fail of PlayQuiz 8. Aborted {err}")
2023-01-29 00:51:30 +01:00
elif number in [4, 5]:
2023-01-29 00:51:30 +01:00
try:
debug(f"Quiz 4 detected on `{nom}`")
2023-01-29 00:51:30 +01:00
play_quiz4()
except Exception as err:
error(f"Fail of PlayQuiz 4. Aborted {err}.")
2023-01-29 00:51:30 +01:00
elif number in [2, 3]:
2023-01-29 00:51:30 +01:00
try:
debug(f"\033[96mQuiz 2 detected on `{nom}`\033[0m")
2023-01-29 00:51:30 +01:00
play_quiz2()
except Exception as err:
error(f"fail of PlayQuiz 2. Aborted {err}")
2023-01-29 00:51:30 +01:00
else:
error("`rqAnswerOption` present in page but no action to do.")
custom_sleep(uniform(3, 5))
2023-01-29 00:51:30 +01:00
2023-05-30 20:21:25 +02:00
if "pas connecté à Microsoft Rewards" in driver.page_source:
custom_sleep(5)
2023-05-30 20:21:25 +02:00
driver.find_element(By.CSS_SELECTOR, '[onclick="setsrchusr()"]').click()
custom_sleep(5)
rgpd_popup(driver)
custom_sleep(5)
debug("Detected and fixed connection popup")
2023-01-29 00:51:30 +01:00
if "bt_PollRadio" in driver.page_source:
debug("Poll detected")
do_poll()
2023-01-29 00:51:30 +01:00
elif "rqQuestionState" in driver.page_source:
number = driver.page_source.count("rqAnswerOption")
warning(f"recovery détecté. quiz : {number}")
play(number - 1)
2023-01-29 00:51:30 +01:00
elif search("([0-9]) de ([0-9]) finalisée", driver.page_source):
info("On fidelity page.")
fidelity()
elif wait_until_visible(By.ID, "rqStartQuiz", 5, driver):
custom_sleep(3)
driver.find_element(By.ID, "rqStartQuiz").click() # start the quiz
answer_number = driver.page_source.count("rqAnswerOption")
play(answer_number)
else:
printf(f"Nothing to do on page `{nom}`")
custom_sleep(uniform(3, 5))
2023-01-29 00:51:30 +01:00
2023-04-12 18:25:12 +02:00
# Login with password or with cookies.
# The driver should be in the same state on both case
2024-02-27 00:33:48 +01:00
def pwd_login(ldriver, cred: UserCredentials):
2023-04-12 18:25:12 +02:00
printf("pwd_login : start")
ldriver.get("https://login.live.com")
wait_until_visible(By.ID, "i0116", browser=ldriver)
2023-04-12 18:25:12 +02:00
mail_elem = ldriver.find_element(By.ID, "i0116")
2024-02-27 00:33:48 +01:00
send_keys_wait(mail_elem, cred.get_mail())
2023-04-12 18:25:12 +02:00
mail_elem.send_keys(Keys.ENTER)
wait_until_visible(By.ID, "i0118", browser=ldriver)
2023-04-12 18:25:12 +02:00
pwd_elem = ldriver.find_element(By.ID, "i0118")
2024-02-27 00:33:48 +01:00
send_keys_wait(pwd_elem, cred.get_password())
2023-04-12 18:25:12 +02:00
pwd_elem.send_keys(Keys.ENTER)
custom_sleep(2)
# 2FA
if "Entrez le code de sécurité" in ldriver.page_source:
try:
2023-04-12 18:25:12 +02:00
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:
2023-04-12 18:25:12 +02:00
log_error(e)
def cookie_login(ldriver):
printf("cookies_login : start")
ldriver.get("https://login.live.com")
try:
2023-04-12 18:25:12 +02:00
load_cookies(ldriver)
except FileNotFoundError:
2023-04-12 18:25:12 +02:00
printf("No cookies file Found.")
return (False)
except Exception as e:
# log_error(f"Error performing cookies login. Trying with password instead. \n{str(e)}", driver)
2023-06-24 16:39:42 +02:00
print("error with cookies login. IDK why (yet)")
return (False)
try:
2023-04-25 21:56:29 +02:00
ldriver.refresh()
except Exception as e:
printf(format_error(e))
printf("FIX YOUR SITE MS.......")
return (True)
2023-04-12 18:25:12 +02:00
# Accept all cookies question, and check if the account is locked
def login_part_2(ldriver, cookies=False):
2023-04-12 18:25:12 +02:00
custom_sleep(5)
if ('Abuse' in ldriver.current_url):
2023-04-12 18:25:12 +02:00
raise Banned()
if ('identity' in ldriver.current_url):
2023-05-04 17:49:51 +02:00
raise Identity()
if ('notice' in ldriver.current_url):
2023-05-04 17:49:51 +02:00
ldriver.find_element(By.ID, "id__0").click()
if ("proof" in ldriver.current_url):
ldriver.find_element(By.ID, "iLooksGood")
2023-04-12 18:25:12 +02:00
if cookies:
save_cookies(ldriver)
2023-10-07 11:56:37 +02:00
for id in ["iNext", "KmsiCheckboxField", "id__0", "iLooksGood", "idSIButton9", "iCancel"]:
2023-04-12 18:25:12 +02:00
if get_domain(ldriver) == "account.microsoft.com":
break
try:
ldriver.find_element(By.ID, id).click()
except Exception as e:
2023-01-29 00:51:30 +01:00
pass
2023-04-12 18:25:12 +02:00
wait_until_visible(By.CSS_SELECTOR, '[data-bi-id="sh-sharedshell-home"]', 20, ldriver)
2023-09-24 22:23:52 +02:00
2023-05-04 17:49:51 +02:00
2023-04-12 18:25:12 +02:00
# login() tries to login to your Microsoft account.
# it uses global variable g._mail and g._password to login
2024-02-27 00:33:48 +01:00
def login(ldriver, cred: Credentials):
try:
2024-02-27 00:33:48 +01:00
pwd_login(ldriver, cred)
2023-09-24 21:48:35 +02:00
login_part_2(ldriver, 0)
2023-04-13 22:22:06 +02:00
ldriver.get("https://rewards.bing.com/")
except Banned:
raise Banned()
2023-05-04 17:49:51 +02:00
except Identity:
raise Banned()
except Exception as e:
log_error(e)
ldriver.quit()
return (False)
2023-01-29 00:51:30 +01:00
# Makes 30 search as PC Edge
def bing_pc_search(override=randint(35, 40)):
mot = choice(Liste_de_mot).replace(" ", "+")
driver.get(f"https://www.bing.com/search?q={mot}") # {choice(Liste_de_mot)}')
2023-01-29 00:51:30 +01:00
custom_sleep(uniform(1, 2))
rgpd_popup(driver)
2023-01-29 00:51:30 +01:00
send_keys_wait(
driver.find_element(By.ID, "sb_form_q"),
Keys.BACKSPACE + Keys.BACKSPACE + Keys.BACKSPACE + Keys.BACKSPACE + Keys.BACKSPACE + Keys.BACKSPACE
2023-01-29 00:51:30 +01:00
)
for _ in range(override):
word = choice(Liste_de_mot)
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:
2023-01-29 00:51:30 +01:00
printf(e)
sleep(10)
driver.get(f'https://www.bing.com/search?q={word}')
sleep(3)
send_keys_wait(driver.find_element(By.ID, "sb_form_q"), word)
driver.find_element(By.ID, "sb_form_q").send_keys(Keys.ENTER)
custom_sleep(uniform(3, 7))
2023-01-29 00:51:30 +01:00
try:
driver.find_element(By.ID, "sb_form_q").clear()
except Exception as e:
printf(e)
try:
2023-02-25 19:05:47 +01:00
driver.get('https://www.bing.com/search?q=plans')
2023-01-29 00:51:30 +01:00
driver.find_element(By.ID, "sb_form_q").clear()
except Exception as e:
2023-03-18 19:12:27 +01:00
log_error(f"clear la barre de recherche - {format_error(e)}")
2023-03-19 18:50:29 +01:00
2023-01-29 00:51:30 +01:00
2023-02-25 19:05:47 +01:00
# Sends points to database, discord and whatever service you want
def log_points(account="unknown"):
2023-01-29 00:51:30 +01:00
def get_points():
2023-04-12 00:01:24 +02:00
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"]:
try:
driver.find_element(By.ID, id).click()
except Exception as e:
pass
2023-04-12 00:01:24 +02:00
wait_until_visible(By.CSS_SELECTOR, 'span[mee-element-ready="$ctrl.loadCounterAnimation()"]', browser=driver)
try:
2023-04-12 00:01:24 +02:00
point = search('availablePoints\":([\d]+)', driver.page_source)[1]
2023-01-29 00:51:30 +01:00
except Exception as e:
2023-04-12 00:01:24 +02:00
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)
2023-04-12 00:01:24 +02:00
driver.refresh()
sleep(5)
point = search('availablePoints\":([\d]+)', driver.page_source)[1]
return (point)
2023-01-29 00:51:30 +01:00
for _ in range(3):
try:
2023-01-29 00:51:30 +01:00
points = get_points()
break
except Exception as e:
custom_sleep(300)
2023-03-18 19:12:27 +01:00
log_error(e)
2023-01-29 00:51:30 +01:00
points = None
if not points:
2023-03-18 19:12:27 +01:00
log_error(f"impossible d'avoir les points")
2023-01-29 00:51:30 +01:00
custom_sleep(uniform(3, 20))
account_name = account.split("@")[0]
2023-04-15 11:03:47 +02:00
if g.discord_enabled_success:
if g.discord_embed:
2023-03-27 22:47:29 +02:00
embed = Embed(
2023-01-29 00:51:30 +01:00
title=f"{account_name} actuellement à {str(points)} points", colour=Colour.green()
)
embed.set_footer(text=account_name)
webhookSuccess.send(embed=embed)
else:
webhookSuccess.send(f"{account_name} actuellement à {str(points)} points")
try:
add_to_database(account_name, points)
except Exception as e:
log_error(e)
2023-01-29 00:51:30 +01:00
2023-01-29 00:51:30 +01:00
def 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:
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:
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]
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]
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')
recover_elem.click()
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))
driver.switch_to.window(driver.window_handles[2])
try_play(driver.title)
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)
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
2023-05-31 10:52:45 +02:00
pause.click()
except Exception as e:
2023-07-03 21:29:26 +02:00
printf(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"]')
for i in range(nb_cartes):
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):
elm = driver.find_elements(By.CLASS_NAME, 'clickable-link')[i]
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])
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"]')
2023-01-29 00:51:30 +01:00
2023-01-29 00:51:30 +01:00
def mobile_alert_popup():
try:
alert = mobile_driver.switch_to.alert
alert.dismiss()
except exceptions.NoAlertPresentException as e:
pass
except Exception as e:
2023-03-18 19:12:27 +01:00
log_error(e, mobile_driver)
2023-01-29 00:51:30 +01:00
def bing_mobile_search(override=randint(22, 25)):
global mobile_driver
mobile_driver = create_driver(mobile=True)
2023-01-29 00:51:30 +01:00
try:
login(mobile_driver)
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:
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)
custom_sleep(uniform(3, 7))
mobile_alert_popup() # check for alert (asking for position or for allowing notifications)
mobile_driver.find_element(By.ID, "sb_form_q").clear()
except Exception as e:
2023-04-04 12:55:00 +02:00
printf(e)
mobile_driver.refresh()
custom_sleep(30)
i -= 1
mobile_driver.quit()
2023-01-29 00:51:30 +01:00
except Exception as e:
2023-03-18 19:12:27 +01:00
log_error(e, mobile_driver)
2023-01-29 00:51:30 +01:00
mobile_driver.quit()
2024-02-27 00:33:48 +01:00
def daily_routine(cred: UserCredentials, custom=False):
try:
if not custom: # custom already login
2024-02-27 00:33:48 +01:00
login(driver, cred)
except Banned:
2024-02-27 00:33:48 +01:00
log_error("This account is locked.", driver)
return
except Identity:
2024-02-27 00:33:48 +01:00
log_error("This account has an issue.", driver)
return
2023-01-29 00:51:30 +01:00
try:
all_cards()
2023-05-12 14:53:52 +02:00
except Banned:
log_error("banned", driver)
return ("BANNED")
2023-01-29 00:51:30 +01:00
except Exception as e:
2023-03-18 19:12:27 +01:00
log_error(e)
2023-01-29 00:51:30 +01:00
2023-04-02 12:32:21 +02:00
try:
fidelity()
except Exception as e:
log_error(e)
2023-01-29 00:51:30 +01:00
try:
bing_pc_search()
except Exception as e:
2023-03-18 19:12:27 +01:00
log_error(e)
2023-04-25 21:56:29 +02:00
2023-07-03 21:29:26 +02:00
try:
bing_mobile_search()
except Exception as e:
log_error(e)
2023-01-29 00:51:30 +01:00
try:
2023-04-12 18:25:12 +02:00
log_points(g._mail)
2023-01-29 00:51:30 +01:00
except Exception as e:
2023-03-18 19:12:27 +01:00
log_error(e)
2023-01-29 00:51:30 +01:00
2024-02-27 00:33:48 +01:00
def json_start(json):
2023-09-30 19:26:17 +02:00
global driver
display = SmartDisplay(backend="xvnc", size=(1920, 1080), rfbport=2345, color_depth=24)
display.start()
for i in range(5):
2023-09-30 17:53:16 +02:00
cred = g._cred[i]
g._mail = cred[0]
g._password = cred[1]
if cred[2] != '':
g._otp = TOTP(cred[2])
2023-09-30 18:02:14 +02:00
start = False
for j in ["unban", "tout", "pc", "mobile", "daily"]:
try:
if str(i) in json[j]:
start = True
print(f"{g._mail} : {j}")
except KeyError:
pass
if start:
driver = create_driver()
try:
if str(i) in json["unban"]:
2024-02-27 00:33:48 +01:00
pwd_login(driver)
print("\nGO TO example.com TO PROCEED or wait 1200 secs.")
for _ in range(1200):
sleep(1)
2023-09-30 18:32:02 +02:00
if driver.current_url == "https://example.com/":
print("proceeding")
break
else:
login(driver)
except KeyError:
login(driver)
try:
if str(i) in json["tout"]:
daily_routine(True)
except KeyError:
pass
# 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:
pass
# 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:
pass
try:
if str(i) in json["mobile"]:
try:
bing_mobile_search()
except Exception as e:
log_error(e)
except KeyError:
pass
try:
log_points(g._mail)
except Exception as e:
printf(f"CustomStart {e}")
2023-09-30 18:04:16 +02:00
driver.close()
display.stop()
if g.very_custom:
2023-09-30 17:53:16 +02:00
dict_data = json.loads(g.very_custom.replace("'", "\""))
2024-02-27 00:33:48 +01:00
json_start(dict_data)
else:
2024-02-27 00:33:48 +01:00
c = Config(args)
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()
2024-02-27 00:33:48 +01:00
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")
while c.UserCredentials.is_valid():
g._mail = c.UserCredentials.get_mail()
g._password = c.UserCredentials.get_password()
if c.UserCredentials.tfa_enable():
g._otp = TOTP(c.UserCredentials.get_tfa())
custom_sleep(1)
info("Starting driver.")
driver = create_driver()
2024-02-27 00:33:48 +01:00
info("Driver started.")
driver.implicitly_wait(3)
try:
2024-02-27 00:33:48 +01:00
wait_time = uniform(1200, 3600)
info(f"Waiting for {round(wait_time / 60)}min before starting")
daily_routine(c.UserCredentials)
driver.quit()
custom_sleep(wait_time)
except KeyboardInterrupt:
critical("Canceled by user. Closing driver and display.")
driver.quit()
display.stop()
break
except Exception as e:
log_error(f"Error not caught. Skipping this account. " + format_error(e), driver)
critical(f"Error not caught. Skipping this account. {e}")
driver.quit()
2024-02-27 00:33:48 +01:00
c.UserCredentials.next_account()
display.stop()