2023-01-29 00:51:30 +01:00
#!/usr/bin/python3.10
from modules . config import *
from modules . error import *
2023-03-27 22:20:54 +02:00
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 "
2024-01-17 17:22:26 +01:00
)
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 } " )
2024-01-17 17:22:26 +01:00
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
2024-02-22 09:38:17 +01:00
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 :
2024-01-17 17:22:26 +01:00
try :
2024-02-22 09:38:17 +01:00
f . write ( l_driver . page_source )
2024-01-17 17:22:26 +01:00
except :
2023-03-29 23:09:16 +02:00
f . write ( " the driver has closed or crashed. Can ' t access page content " )
2024-01-17 17:22:26 +01:00
try :
2023-03-26 22:56:57 +02:00
img = display . waitgrab ( )
img . save ( " screenshot.png " )
2024-01-17 17:22:26 +01:00
except :
2024-02-22 09:38:17 +01:00
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 )
2024-01-17 17:22:26 +01:00
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-03-25 18:14:41 +01:00
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.
# 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
def play_quiz2 ( override = 10 ) - > None :
printf ( " starting play_quiz2 " )
for j in range ( override ) :
try :
2023-04-07 23:28:48 +02:00
# rgpd_popup(driver)
2023-01-29 00:51:30 +01:00
custom_sleep ( uniform ( 3 , 5 ) )
2023-08-13 20:37:21 +02:00
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 )
answer_elem = driver . find_element ( By . ID , f " rqAnswerOption { correct_answer_value } " )
answer_elem . click ( )
if g . log :
progressBar ( j , 10 , name = " quiz 2 " )
2023-01-29 00:51:30 +01:00
except exceptions . ElementNotInteractableException as e :
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
printf ( " play_quiz2 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-01-17 17:22:26 +01:00
override = len ( findall ( " <span id= \" rqQuestionState. \" class= \" emptyCircle \" ></span> " , driver . page_source ) ) + 1
2023-01-29 00:51:30 +01:00
printf ( f " play_quiz8 : start, override : { override } " )
try :
counter = 0
2023-04-07 23:28:48 +02:00
# rgpd_popup(driver)
2024-01-17 17:22:26 +01:00
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-01-17 17:22:26 +01:00
for i in range ( 1 , 9 ) :
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 " ) :
2024-01-17 17:22:26 +01:00
correct_answers . append ( f ' rqAnswerOption { i - 1 } ' )
except Exception as e :
printf ( 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 :
2024-01-17 17:22:26 +01:00
wait_until_visible ( By . ID , answer_id , timeout = 20 , browser = driver )
2023-01-29 00:51:30 +01:00
counter + = 1
2024-01-17 17:22:26 +01:00
if g . log :
2023-04-17 22:28:26 +02:00
progressBar ( counter , 16 , name = " Quiz 8 " )
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 )
2024-01-17 17:22:26 +01:00
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 ( )
2024-01-17 17:22:26 +01:00
except ElementClickInterceptedException :
2023-03-25 18:14:41 +01:00
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 ) } " )
2023-04-15 11:03:47 +02:00
custom_sleep ( 3 )
2023-01-29 00:51:30 +01:00
2024-02-22 09:38:17 +01:00
def play_quiz4 ( override : int = None ) :
2023-01-29 00:51:30 +01:00
printf ( " play_quiz4 : start " )
if not override :
try : # fidelity quiz are much longer than usual ones
override = int ( findall ( ' rqQuestionState([ \ d] { 1,2}) " ' , driver . page_source ) [ - 1 ] )
printf ( f " Override : { override } " )
except :
override = 3
try :
for i in range ( override ) :
custom_sleep ( uniform ( 3 , 5 ) )
txt = driver . page_source
2023-04-07 23:28:48 +02:00
# rgpd_popup(driver)
2023-01-29 00:51:30 +01:00
answer_option = search ( ' correctAnswer " : " ([^ " ]+) ' , txt ) [ 1 ]
2024-01-17 17:22:26 +01:00
answer_option = answer_option . replace ( " \\ u0027 " , " ' " ) # replace Unicode weird symbols
2023-01-29 00:51:30 +01:00
try :
answer_element = driver . find_element ( By . CSS_SELECTOR , f ' [data-option= " { answer_option } " ] ' )
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 )
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 ( ) :
printf ( " do_poll : start " )
try :
try :
2024-01-17 17:22:26 +01:00
answer_elem = driver . find_element ( By . ID , f " btoption { choice ( [ 0 , 1 ] ) } " )
2023-01-29 00:51:30 +01:00
answer_elem . click ( )
except exceptions . ElementNotInteractableException :
driver . execute_script ( " arguments[0].click(); " , answer_elem )
custom_sleep ( uniform ( 2 , 2.5 ) )
except Exception as error :
2023-03-18 19:12:27 +01:00
log_error ( error )
2023-01-29 00:51:30 +01:00
raise ValueError ( error )
2023-04-15 11:03:47 +02:00
custom_sleep ( 3 )
2023-01-29 00:51:30 +01:00
2023-04-13 22:22:06 +02:00
def all_cards ( ) :
2024-01-17 17:22:26 +01:00
# input("1")
2023-04-13 22:22:06 +02:00
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 )
2024-01-17 17:22:26 +01:00
try :
2023-04-13 22:22:06 +02:00
promo ( )
2023-01-29 00:51:30 +01:00
except Exception as e :
2023-04-13 22:22:06 +02:00
printf ( " no promo card " )
2024-01-17 17:22:26 +01:00
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 ( )
2023-05-05 11:40:38 +02:00
driver . refresh ( )
liste = driver . find_elements ( By . CLASS_NAME , " c-card-content " )
2024-01-17 17:22:26 +01:00
if ( len ( liste ) < 10 ) :
2023-05-09 13:09:14 +02:00
log_error ( " Less than 10 cards. Most likely an error with login. " , driver )
2024-01-17 17:22:26 +01:00
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 } " )
2024-01-17 17:22:26 +01:00
try :
2023-04-13 22:22:06 +02:00
checked = ( " mee-icon-AddMedium " in liste [ i ] . get_attribute ( " innerHTML " ) )
2024-01-17 17:22:26 +01:00
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 :
2023-05-09 13:09:14 +02:00
driver . get ( " https://rewards.bing.com " )
2023-04-17 22:00:46 +02:00
custom_sleep ( 10 )
2023-05-05 11:40:38 +02:00
liste = driver . find_elements ( By . CLASS_NAME , " c-card-content " )
2024-01-17 17:22:26 +01:00
try :
2023-05-05 11:40:38 +02:00
checked = ( " mee-icon-AddMedium " in liste [ i ] . get_attribute ( " innerHTML " ) )
2024-01-17 17:22:26 +01:00
except IndexError :
if i == len ( liste ) & i > 15 :
2023-05-30 20:21:25 +02:00
checked = False
2024-01-17 17:22:26 +01:00
# input("2")
2023-04-13 22:22:06 +02:00
if checked :
2023-05-05 11:40:38 +02:00
custom_sleep ( 1.5 )
2023-04-13 22:22:06 +02:00
driver . execute_script ( " arguments[0].scrollIntoView(); " , liste [ i ] )
2023-05-05 11:40:38 +02:00
custom_sleep ( 1.5 )
2024-01-17 17:22:26 +01:00
# input("3")
2023-04-13 22:22:06 +02:00
liste [ i ] . click ( )
2024-01-17 17:22:26 +01:00
# input("4")
if len ( driver . window_handles ) > 1 :
2023-04-13 22:22:06 +02:00
driver . switch_to . window ( driver . window_handles [ 1 ] )
2024-01-17 17:22:26 +01:00
# 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 ] )
2024-01-17 17:22:26 +01:00
try :
2023-04-13 22:22:06 +02:00
driver . refresh ( )
liste = driver . find_elements ( By . CLASS_NAME , " c-card-content " )
2024-01-17 17:22:26 +01:00
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. " )
2024-01-17 17:22:26 +01:00
try :
2023-05-04 17:49:51 +02:00
liste [ i ] . click ( )
2024-01-17 17:22:26 +01:00
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 ] )
2023-05-05 11:40:38 +02:00
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 :
2024-01-17 17:22:26 +01:00
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
2024-01-17 17:22:26 +01:00
except :
2023-05-30 20:21:25 +02:00
driver . get ( " https://rewards.bing.com " )
2024-01-17 17:22:26 +01:00
except :
2023-04-13 22:22:06 +02:00
pass
2024-01-17 17:22:26 +01:00
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
2024-01-17 17:22:26 +01:00
if i > 3 :
2023-05-31 10:52:45 +02:00
log_error ( " plus de 3 promo cards, probablement une pa skipable " , driver )
2024-01-17 17:22:26 +01:00
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 } " )
2024-01-17 17:22:26 +01:00
return ( )
try :
2023-05-09 13:09:14 +02:00
elm . click ( )
2023-05-30 20:21:25 +02:00
except Exception as e :
2024-01-17 17:22:26 +01:00
# log_error(e, driver)
2023-05-09 13:09:14 +02:00
driver . execute_script ( " arguments[0].click(); " , elm )
2024-01-17 17:22:26 +01:00
# 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 )
2024-01-17 17:22:26 +01:00
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 ] )
2024-01-17 17:22:26 +01:00
else :
try :
2023-04-17 22:00:46 +02:00
spotify ( driver )
2024-01-17 17:22:26 +01:00
except :
2023-05-04 17:49:51 +02:00
printf ( " no new windows " , driver )
2023-04-14 10:31:12 +02:00
driver . get ( " https://rewards.bing.com " )
2023-05-09 13:09:14 +02:00
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 )
2024-01-17 17:22:26 +01:00
2023-01-29 00:51:30 +01:00
def play ( number ) :
if number == 8 or number == 9 :
try :
2023-04-12 00:01:24 +02:00
printf ( f " \033 [96mQuiz 8 detected on ` { nom } ` \033 [0m " )
2023-03-19 18:50:29 +01:00
play_quiz8 ( )
2023-04-12 00:01:24 +02:00
printf ( f " \033 [92mQuiz 8 succeeded on ` { nom } ` \033 [0m " )
2023-03-14 16:52:46 +01:00
custom_sleep ( uniform ( 3 , 5 ) )
2023-01-29 00:51:30 +01:00
except Exception as e :
printf ( f " fail of PlayQuiz 8. Aborted { e } \033 [0m " )
elif number == 5 or number == 4 :
try :
2023-04-12 00:01:24 +02:00
printf ( f " \033 [96mQuiz 4 detected on ` { nom } ` \033 [0m " )
2023-01-29 00:51:30 +01:00
play_quiz4 ( )
2023-04-12 00:01:24 +02:00
printf ( f " \033 [92mQuiz 4 succeeded on ` { nom } ` \033 [0m " )
2023-03-14 16:52:46 +01:00
custom_sleep ( uniform ( 3 , 5 ) )
2023-01-29 00:51:30 +01:00
except Exception as e :
2023-04-12 00:01:24 +02:00
printf ( f " Fail of PlayQuiz 4. Aborted { e } \033 [0m " )
2023-01-29 00:51:30 +01:00
elif number == 3 or number == 2 :
try :
2023-04-12 00:01:24 +02:00
printf ( f " \033 [96mQuiz 2 detected on ` { nom } ` \033 [0m " )
2023-01-29 00:51:30 +01:00
play_quiz2 ( )
2023-04-12 00:01:24 +02:00
printf ( f " \033 [92mQuiz 2 succeeded on ` { nom } ` \033 [0m " )
2023-01-29 00:51:30 +01:00
except Exception as e :
printf ( f " fail of PlayQuiz 2. Aborted { e } " )
else :
2023-05-05 11:40:38 +02:00
printf ( " There is an error. rqAnswerOption present in page but no action to do. skipping. " )
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 :
2023-09-24 21:42:27 +02:00
custom_sleep ( 5 )
2023-05-30 20:21:25 +02:00
driver . find_element ( By . CSS_SELECTOR , ' [onclick= " setsrchusr() " ] ' ) . click ( )
custom_sleep ( 5 )
2023-09-24 22:28:51 +02:00
rgpd_popup ( driver )
custom_sleep ( 5 )
2023-05-30 20:21:25 +02:00
printf ( " not connected, fixed " )
2023-09-06 16:04:42 +02:00
if " legaltextbox " in driver . current_url :
2023-09-20 11:46:35 +02:00
log_error ( " dev1 " )
2023-09-06 16:04:42 +02:00
driver . find_element ( By . CLASS_NAME , " actionLink " ) . click ( )
2023-09-20 11:46:35 +02:00
log_error ( " dev2 " )
2023-01-29 00:51:30 +01:00
try :
2023-04-13 22:22:06 +02:00
if 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 )
2024-01-17 17:22:26 +01:00
else :
raise ( NameError ( " going to next part " ) )
except Exception as e : # if there is no start button, an error is thrown
2023-01-29 00:51:30 +01:00
if " bt_PollRadio " in driver . page_source :
try :
printf ( " Poll detected " )
do_poll ( )
printf ( " Poll succeeded " )
except Exception as e :
printf ( f " try_play - 1 - Poll aborted { e } " )
elif " rqQuestionState " in driver . page_source :
try :
number = driver . page_source . count ( " rqAnswerOption " )
printf ( f " recovery détecté. quiz : { number } " )
2024-01-17 17:22:26 +01:00
play ( number - 1 )
2023-01-29 00:51:30 +01:00
except Exception as e :
printf ( f " try_play - 2 - { e } " )
elif search ( " ([0-9]) de ([0-9]) finalisée " , driver . page_source ) :
2023-04-04 12:55:00 +02:00
printf ( " fidélité " )
2023-01-29 00:51:30 +01:00
fidelity ( )
else :
printf ( f " rien à faire sur la page { nom } " )
custom_sleep ( uniform ( 3 , 5 ) )
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 " )
2024-01-17 17:22:26 +01:00
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 )
2024-01-17 17:22:26 +01:00
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
2024-01-17 17:22:26 +01:00
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 )
2024-01-17 17:22:26 +01:00
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 " )
2024-01-17 17:22:26 +01:00
try :
2023-04-12 18:25:12 +02:00
load_cookies ( ldriver )
2024-01-17 17:22:26 +01:00
except FileNotFoundError :
2023-04-12 18:25:12 +02:00
printf ( " No cookies file Found. " )
2024-01-17 17:22:26 +01:00
return ( False )
2023-05-05 11:56:26 +02:00
except Exception as e :
2024-01-17 17:22:26 +01:00
# 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) " )
2024-01-17 17:22:26 +01:00
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....... " )
2024-01-17 17:22:26 +01:00
return ( True )
2023-04-12 18:25:12 +02:00
# Accept all cookies question, and check if the account is locked
2024-01-17 17:22:26 +01:00
def login_part_2 ( ldriver , cookies = False ) :
2023-04-12 18:25:12 +02:00
custom_sleep ( 5 )
2024-01-17 17:22:26 +01:00
if ( ' Abuse ' in ldriver . current_url ) :
2023-04-12 18:25:12 +02:00
raise Banned ( )
2024-01-17 17:22:26 +01:00
if ( ' identity ' in ldriver . current_url ) :
2023-05-04 17:49:51 +02:00
raise Identity ( )
2024-01-17 17:22:26 +01:00
if ( ' notice ' in ldriver . current_url ) :
2023-05-04 17:49:51 +02:00
ldriver . find_element ( By . ID , " id__0 " ) . click ( )
2023-05-09 13:09:14 +02:00
if ( " proof " in ldriver . current_url ) :
2024-01-17 17:22:26 +01:00
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 ) :
2024-01-17 17:22:26 +01:00
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/ " )
2023-03-25 18:14:41 +01:00
except Banned :
raise Banned ( )
2023-05-04 17:49:51 +02:00
except Identity :
raise Banned ( )
2023-03-25 18:14:41 +01:00
except Exception as e :
log_error ( e )
ldriver . quit ( )
2024-01-17 17:22:26 +01:00
return ( False )
2023-01-29 00:51:30 +01:00
# Makes 30 search as PC Edge
def bing_pc_search ( override = randint ( 35 , 40 ) ) :
2024-01-17 17:22:26 +01:00
mot = choice ( Liste_de_mot ) . replace ( " " , " + " )
2023-03-19 10:44:00 +01:00
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 ) )
2023-03-25 18:14:41 +01:00
rgpd_popup ( driver )
2023-01-29 00:51:30 +01:00
send_keys_wait (
driver . find_element ( By . ID , " sb_form_q " ) ,
2024-01-17 17:22:26 +01:00
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 )
2024-01-17 17:22:26 +01:00
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 )
2023-04-12 13:29:06 +02:00
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
2024-01-17 17:22:26 +01:00
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 " )
2023-04-12 13:29:06 +02:00
custom_sleep ( 1 )
if " /proofs/ " in driver . current_url :
2024-01-17 17:22:26 +01:00
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 " ] :
2023-04-12 13:29:06 +02:00
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 )
2024-01-17 17:22:26 +01:00
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 )
2024-01-17 17:22:26 +01:00
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 ]
2024-01-17 17:22:26 +01:00
return ( point )
2023-01-29 00:51:30 +01:00
2024-01-17 17:22:26 +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
2023-08-25 11:43:09 +02:00
2024-01-17 17:22:26 +01:00
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 " )
2024-01-17 17:22:26 +01:00
try :
2023-08-25 11:43:09 +02:00
add_to_database ( account_name , points )
except Exception as e :
log_error ( e )
2023-01-29 00:51:30 +01:00
2024-01-17 17:22:26 +01:00
2023-01-29 00:51:30 +01:00
def fidelity ( ) :
2024-01-17 17:22:26 +01:00
def sub_fidelity ( ) :
2023-05-07 12:51:38 +02:00
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 )
2024-01-17 17:22:26 +01:00
if answer_number is None :
2023-05-07 12:51:38 +02:00
answer_number = search ( " ([0-9]) 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 )
2024-01-17 17:22:26 +01:00
if answer_number is None :
2023-05-07 12:51:38 +02:00
answer_number = search ( " ([0-9]) licence \ (s \ ) sur ([0-9]) disponible \ (s \ ) " , driver . page_source )
2024-01-17 17:22:26 +01:00
if answer_number is None :
answer_number = [ 0 , 0 , 0 ]
2023-05-07 12:51:38 +02:00
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 " )
2024-01-17 17:22:26 +01:00
try :
button_text = search ( ' <span class= " pull-left margin-right-15 " >([^<^>]+)</span> ' ,
card_elem . get_attribute ( " innerHTML " ) ) [ 1 ]
2023-05-07 12:51:38 +02:00
bouton_card = driver . find_element ( By . XPATH , f ' //span[text()= " { button_text } " ] ' )
bouton_card . click ( )
2024-01-17 17:22:26 +01:00
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 ' )
2023-05-07 12:51:38 +02:00
recover_elem . click ( )
2024-01-17 17:22:26 +01:00
except Exception as e2 :
2023-05-07 12:51:38 +02:00
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 )
2024-01-17 17:22:26 +01:00
2023-05-09 13:09:14 +02:00
if driver . current_url != " https://rewards.bing.com " :
driver . get ( " https://rewards.bing.com " )
2024-01-17 17:22:26 +01:00
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 } " )
2024-01-17 17:22:26 +01:00
return ( " no cards " )
2023-05-07 12:51:38 +02:00
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 ) :
2024-01-17 17:22:26 +01:00
cartes [ i ] . click ( ) # affiche la bonne carte
2023-05-07 12:51:38 +02:00
checked_txt = checked_list_all [ i ] . get_attribute ( " innerHTML " )
ok = checked_txt . count ( " StatusCircleOuter checkmark " )
total = checked_txt . count ( " StatusCircleOuter " )
2024-01-17 17:22:26 +01:00
if ( ok != total ) :
2023-05-07 12:51:38 +02:00
elm = driver . find_elements ( By . CLASS_NAME , ' clickable-link ' ) [ i ]
2024-01-17 17:22:26 +01:00
if not " moviesandtv " in elm . get_attribute ( " innerHTML " ) : # not the film card
2023-05-07 12:51:38 +02:00
elm . click ( )
2024-01-17 17:22:26 +01:00
driver . switch_to . window ( driver . window_handles [ len ( driver . window_handles ) - 1 ] )
2023-05-07 12:51:38 +02:00
sub_fidelity ( )
close_tab ( driver . window_handles [ 1 ] )
custom_sleep ( 1 )
2023-05-09 13:09:14 +02:00
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
2024-01-17 17:22:26 +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
2024-02-22 09:38:17 +01:00
mobile_driver = create_driver ( mobile = True )
2023-01-29 00:51:30 +01:00
try :
2023-03-25 18:14:41 +01:00
login ( mobile_driver )
2024-01-17 17:22:26 +01:00
mot = choice ( Liste_de_mot ) . replace ( " " , " + " )
2023-03-25 18:14:41 +01:00
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
2024-01-17 17:22:26 +01:00
try :
2023-03-25 18:14:41 +01:00
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 )
2023-04-12 13:29:06 +02:00
custom_sleep ( uniform ( 3 , 7 ) )
2023-03-25 18:14:41 +01:00
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 )
2023-03-25 18:14:41 +01:00
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 ) :
2024-01-17 17:22:26 +01:00
try :
if not custom : # custom already login
2024-02-27 00:33:48 +01:00
login ( driver , cred )
2024-01-17 17:22:26 +01:00
except Banned :
2024-02-27 00:33:48 +01:00
log_error ( " This account is locked. " , driver )
return
2024-01-17 17:22:26 +01:00
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 )
2024-01-17 17:22:26 +01:00
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
def dev ( ) :
2023-05-07 12:51:38 +02:00
pass
2023-01-29 00:51:30 +01:00
2023-04-15 11:03:47 +02:00
def CustomStart ( ) :
2024-01-17 17:22:26 +01:00
if not g . islinux :
raise NameError (
' You need to be on linux to do that, due to the utilisation of a module named enquieries, sorry. ' )
2023-04-15 11:03:47 +02:00
global driver
2023-01-29 00:51:30 +01:00
system ( " clear " ) # clear from previous command to allow a clean choice
2024-01-17 17:22:26 +01:00
actions = [ " tout " , " daily " , " pc " , " mobile " , " log_points " , " fidelity " , " dev " ]
2023-01-29 00:51:30 +01:00
Actions = enquiries . choose ( " quels Actions ? " , actions , multi = True )
liste = select_accounts ( )
2024-01-17 17:22:26 +01:00
g . start_time = time ( ) # Reset timer to the start of the actions
2023-01-29 00:51:30 +01:00
2023-03-19 18:50:29 +01:00
for cred in liste :
2023-04-12 18:25:12 +02:00
g . _mail = cred [ 0 ]
g . _password = cred [ 1 ]
2023-03-19 18:50:29 +01:00
if len ( cred ) == 3 :
2023-04-12 18:25:12 +02:00
g . _otp = TOTP ( cred [ 2 ] )
2023-01-29 00:51:30 +01:00
2024-02-22 09:38:17 +01:00
driver = create_driver ( )
2023-03-19 18:50:29 +01:00
driver . implicitly_wait ( 3 )
2023-03-25 18:14:41 +01:00
if login ( driver ) != " STOP " :
2023-03-19 18:50:29 +01:00
if " tout " in Actions :
daily_routine ( True )
if " daily " in Actions :
2024-01-17 17:22:26 +01:00
# input("0")
2023-03-19 18:50:29 +01:00
try :
all_cards ( )
except Exception as e :
log_error ( e )
if " pc " in Actions :
try :
bing_pc_search ( )
except Exception as e :
log_error ( e )
if " mobile " in Actions :
try :
bing_mobile_search ( )
except Exception as e :
log_error ( e )
if " fidelity " in Actions :
2024-01-17 17:22:26 +01:00
try :
2023-03-19 18:50:29 +01:00
fidelity ( )
2024-01-17 17:22:26 +01:00
except Exception as e :
2023-03-19 18:50:29 +01:00
log_error ( e )
if " dev " in Actions :
try :
dev ( )
except Exception as e :
printf ( e )
break
if not " tout " in Actions :
try :
2023-04-12 18:25:12 +02:00
log_points ( g . _mail )
2023-03-19 18:50:29 +01:00
except Exception as e :
2023-04-04 12:55:00 +02:00
printf ( f " CustomStart { e } " )
2023-04-15 11:03:47 +02:00
driver . quit ( )
2023-01-29 00:51:30 +01:00
2024-01-17 17:22:26 +01:00
2024-02-27 00:33:48 +01:00
def json_start ( json ) :
2023-09-30 19:26:17 +02:00
global driver
2024-01-17 17:22:26 +01:00
display = SmartDisplay ( backend = " xvnc " , size = ( 1920 , 1080 ) , rfbport = 2345 , color_depth = 24 )
2023-09-30 17:23:37 +02:00
display . start ( )
for i in range ( 5 ) :
2023-09-30 17:53:16 +02:00
cred = g . _cred [ i ]
2023-09-30 17:23:37 +02:00
g . _mail = cred [ 0 ]
g . _password = cred [ 1 ]
2024-02-23 08:49:00 +01:00
if cred [ 2 ] != ' ' :
g . _otp = TOTP ( cred [ 2 ] )
2023-09-30 18:02:14 +02:00
start = False
2023-10-05 22:06:52 +02:00
for j in [ " unban " , " tout " , " pc " , " mobile " , " daily " ] :
2024-01-17 17:22:26 +01:00
try :
2023-09-30 18:00:43 +02:00
if str ( i ) in json [ j ] :
start = True
2023-09-30 18:36:20 +02:00
print ( f " { g . _mail } : { j } " )
2024-01-17 17:22:26 +01:00
except KeyError :
2023-09-30 18:36:20 +02:00
pass
2023-09-30 17:23:37 +02:00
if start :
2024-02-22 09:38:17 +01:00
driver = create_driver ( )
2024-01-17 17:22:26 +01:00
try :
2023-09-30 18:00:43 +02:00
if str ( i ) in json [ " unban " ] :
2024-02-27 00:33:48 +01:00
pwd_login ( driver )
2024-02-22 09:38:17 +01:00
print ( " \n GO TO example.com TO PROCEED or wait 1200 secs. " )
for _ in range ( 1200 ) :
2023-09-30 18:22:56 +02:00
sleep ( 1 )
2023-09-30 18:32:02 +02:00
if driver . current_url == " https://example.com/ " :
print ( " proceeding " )
2023-09-30 18:22:56 +02:00
break
2024-01-17 17:22:26 +01:00
else :
2023-09-30 18:00:43 +02:00
login ( driver )
2024-01-17 17:22:26 +01:00
except KeyError :
2023-09-30 19:30:42 +02:00
login ( driver )
2024-01-17 17:22:26 +01:00
try :
2023-09-30 18:00:43 +02:00
if str ( i ) in json [ " tout " ] :
daily_routine ( True )
2024-01-17 17:22:26 +01:00
except KeyError :
2023-09-30 18:36:20 +02:00
pass
2024-01-17 17:22:26 +01:00
# print("none is set to \"tout\"")
else :
try :
2023-09-30 18:00:43 +02:00
if str ( i ) in json [ " daily " ] :
try :
2023-09-30 19:30:42 +02:00
all_cards ( )
2023-09-30 18:00:43 +02:00
except Exception as e :
log_error ( e )
2024-01-17 17:22:26 +01:00
except KeyError :
2023-09-30 18:36:20 +02:00
pass
2024-01-17 17:22:26 +01:00
# print("none is set to \"daily\"")
try :
2023-09-30 18:00:43 +02:00
if str ( i ) in json [ " pc " ] :
try :
bing_pc_search ( )
except Exception as e :
log_error ( e )
2024-01-17 17:22:26 +01:00
except KeyError :
2023-09-30 18:36:20 +02:00
pass
2024-01-17 17:22:26 +01:00
try :
2023-09-30 18:00:43 +02:00
if str ( i ) in json [ " mobile " ] :
try :
bing_mobile_search ( )
except Exception as e :
log_error ( e )
2024-01-17 17:22:26 +01:00
except KeyError :
2023-09-30 18:36:20 +02:00
pass
2023-09-30 17:23:37 +02:00
try :
log_points ( g . _mail )
except Exception as e :
printf ( f " CustomStart { e } " )
2024-01-17 17:22:26 +01:00
2023-09-30 18:04:16 +02:00
driver . close ( )
2023-09-30 17:23:37 +02:00
display . stop ( )
2023-09-30 17:41:46 +02:00
2024-01-17 17:22:26 +01:00
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 )
2023-09-30 17:41:46 +02:00
2024-01-17 17:22:26 +01:00
else :
2024-02-27 00:33:48 +01:00
c = Config ( args )
2024-01-17 17:22:26 +01:00
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 ) )
2023-09-30 17:41:46 +02:00
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. " )
2024-02-22 09:38:17 +01:00
driver = create_driver ( )
2024-02-27 00:33:48 +01:00
info ( " Driver started. " )
driver . implicitly_wait ( 3 )
2024-01-17 17:22:26 +01:00
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 ( )
2023-09-30 17:41:46 +02:00
2024-02-27 00:33:48 +01:00
c . UserCredentials . next_account ( )
display . stop ( )