ptite update

This commit is contained in:
piair 2023-04-25 21:56:29 +02:00
parent 710c272659
commit ed1e91b304
9 changed files with 72 additions and 97 deletions

44
V5.py
View File

@ -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")
for i in range(len(liste)):
if(len(liste) < 10):
log_error("moins de 10 cartes", driver)
if (len(liste) < 20):
log_error("moins de 20 cartes", driver)
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)):
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)
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:
@ -682,7 +695,6 @@ def daily_routine(custom = False):
except Exception as e:
log_error(e)
try:
log_points(g._mail)
except Exception as e:

View File

@ -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()

View File

@ -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)

View File

@ -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

View File

@ -21,10 +21,22 @@ def rgpd_popup(driver) -> None:
# save webdriver cookies
def save_cookies(driver):
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):
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)

View File

@ -32,3 +32,5 @@ sql_usr = "None"
sql_pwd = "azerty"
sql_host = "https://example.com"
sql_database = "MsRewards"
dev = False
norvege = False

View File

@ -26,6 +26,7 @@ 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:

View File

@ -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("")

View File

@ -1 +1 @@
v5.9.4
v5.10.0