From ca4f97c07bd7c54084b8daa1e1bc8376fe2348c4 Mon Sep 17 00:00:00 2001 From: piair Date: Sun, 13 Aug 2023 20:37:21 +0200 Subject: [PATCH] fix --- V6.py | 40 +++++++++++++++++++++------------------- version | 2 +- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/V6.py b/V6.py index fd8af84..33a5ade 100755 --- a/V6.py +++ b/V6.py @@ -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,26 +92,27 @@ 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") - answer_elem.click() - if g.log: - progressBar(j, 10, name="quiz 2") + 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") except exceptions.ElementNotInteractableException as e: driver.execute_script("arguments[0].click();", answer_elem) diff --git a/version b/version index c3e1034..9e515dc 100644 --- a/version +++ b/version @@ -1 +1 @@ -v6.0.10 +v6.0.11