This commit is contained in:
piair 2023-08-13 20:37:21 +02:00
parent 659e7d3664
commit ca4f97c07b
2 changed files with 22 additions and 20 deletions

34
V6.py
View File

@ -83,6 +83,7 @@ def close_tab(tab, SwitchTo=0) -> None:
driver.switch_to.window(driver.window_handles[SwitchTo])
# 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:
@ -91,23 +92,24 @@ def play_quiz2(override=10) -> None:
try:
# rgpd_popup(driver)
custom_sleep(uniform(3, 5))
page_html = driver.page_source
secret_answer = search('IG:"([^"]+)"', page_html)[1] # variable used to calculate offset
answers_values = search('data-option="([^"]+)"', page_html)[1]
offset = int(secret_answer[-2:], 16) # the last two character converted to int are the offset
correct_answer_value = search('correctAnswer":"([0-9]+)', page_html)[1]
somme = 0
for answer in answers_values:
somme += ord(answer)
if somme + offset == int(correct_answer_value):
answer_elem = driver.find_element(By.ID, "rqAnswerOption0")
answer_elem.click()
if g.log:
progressBar(j, 10, name="quiz 2")
else:
answer_elem = driver.find_element(By.ID, "rqAnswerOption1")
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")

View File

@ -1 +1 @@
v6.0.10
v6.0.11