From 600433be1ff6ff94f1d1b66968d565118760d2a0 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 16 Jan 2024 14:24:21 +0800 Subject: [PATCH] 2024-01-08, bugs fix. --- chrome_tixcraft.py | 9 ++- config_launcher.py | 2 +- settings.json | 71 ++++++++++++++++++- settings.py | 14 ++-- webdriver/Maxbotplus_1.0.0/data/settings.json | 2 +- .../Maxbotplus_1.0.0/js/tixcraft_ticket.js | 13 +++- 6 files changed, 96 insertions(+), 15 deletions(-) diff --git a/chrome_tixcraft.py b/chrome_tixcraft.py index 8861aa3..bb34666 100644 --- a/chrome_tixcraft.py +++ b/chrome_tixcraft.py @@ -41,7 +41,7 @@ try: except Exception as exc: pass -CONST_APP_VERSION = "MaxBot (2024.01.07)" +CONST_APP_VERSION = "MaxBot (2024.01.08)" CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt" CONST_MAXBOT_CONFIG_FILE = "settings.json" @@ -2971,10 +2971,9 @@ def get_answer_list_from_user_guess_string(config_dict): # load from internet. user_guess_string = "" - if len(config_dict["advanced"]["online_dictionary_url"]) > 0: - if os.path.exists(CONST_MAXBOT_ANSWER_ONLINE_FILE): - with open(CONST_MAXBOT_ANSWER_ONLINE_FILE, "r") as text_file: - user_guess_string = text_file.readline() + if os.path.exists(CONST_MAXBOT_ANSWER_ONLINE_FILE): + with open(CONST_MAXBOT_ANSWER_ONLINE_FILE, "r") as text_file: + user_guess_string = text_file.readline() if len(user_guess_string) > 0: user_guess_string = format_config_keyword_for_json(user_guess_string) try: diff --git a/config_launcher.py b/config_launcher.py index 423cc5e..ce9aafb 100644 --- a/config_launcher.py +++ b/config_launcher.py @@ -22,7 +22,7 @@ import sys import threading import webbrowser -CONST_APP_VERSION = "MaxBot (2024.01.07)" +CONST_APP_VERSION = "MaxBot (2024.01.08)" CONST_MAXBOT_LAUNCHER_FILE = "config_launcher.json" CONST_MAXBOT_CONFIG_FILE = "settings.json" diff --git a/settings.json b/settings.json index 2f45fd1..e985cac 100644 --- a/settings.json +++ b/settings.json @@ -1 +1,70 @@ -{"homepage": "https://tixcraft.com", "browser": "chrome", "language": "\u7e41\u9ad4\u4e2d\u6587", "ticket_number": 2, "ocr_captcha": {"enable": true, "beta": true, "force_submit": true, "image_source": "canvas"}, "webdriver_type": "undetected_chromedriver", "date_auto_select": {"enable": true, "date_keyword": "", "mode": "random"}, "area_auto_select": {"enable": true, "mode": "random", "area_keyword": ""}, "keyword_exclude": "\"\u8f2a\u6905\",\"\u8eab\u969c\",\"\u8eab\u5fc3 \u969c\u7919\",\"Restricted View\",\"\u71c8\u67f1\u906e\u853d\",\"\u8996\u7dda\u4e0d\u5b8c\u6574\"", "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true}, "tixcraft": {"pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true}, "advanced": {"play_captcha_sound": {"enable": true, "filename": "ding-dong.wav"}, "tixcraft_sid": "", "ibonqware": "", "facebook_account": "", "kktix_account": "", "fami_account": "", "cityline_account": "", "urbtix_account": "", "hkticketing_account": "", "kham_account": "", "ticket_account": "", "udn_account": "", "ticketplus_account": "", "facebook_password": "", "kktix_password": "", "fami_password": "", "urbtix_password": "", "cityline_password": "", "hkticketing_password": "", "kham_password": "", "ticket_password": "", "udn_password": "", "ticketplus_password": "", "disable_adjacent_seat": false, "hide_some_image": false, "block_facebook_network": false, "headless": false, "verbose": false, "auto_guess_options": true, "user_guess_string": "", "remote_url": "\"http://127.0.0.1:16888/\"", "auto_reload_page_interval": 0.1, "proxy_server_port": ""}} \ No newline at end of file +{ + "homepage": "https://tixcraft.com", + "browser": "chrome", + "language": "\u7e41\u9ad4\u4e2d\u6587", + "ticket_number": 2, + "ocr_captcha": { + "enable": true, + "beta": true, + "force_submit": true, + "image_source": "canvas" + }, + "webdriver_type": "undetected_chromedriver", + "date_auto_select": { + "enable": true, + "date_keyword": "", + "mode": "random" + }, + "area_auto_select": { + "enable": true, + "mode": "random", + "area_keyword": "" + }, + "keyword_exclude": "\"\u8f2a\u6905\",\"\u8eab\u969c\",\"\u8eab\u5fc3 \u969c\u7919\",\"Restricted View\",\"\u71c8\u67f1\u906e\u853d\",\"\u8996\u7dda\u4e0d\u5b8c\u6574\"", + "kktix": { + "auto_press_next_step_button": true, + "auto_fill_ticket_number": true + }, + "tixcraft": { + "pass_date_is_sold_out": true, + "auto_reload_coming_soon_page": true + }, + "advanced": { + "play_captcha_sound": { + "enable": true, + "filename": "ding-dong.wav" + }, + "tixcraft_sid": "", + "ibonqware": "", + "facebook_account": "", + "kktix_account": "", + "fami_account": "", + "cityline_account": "", + "urbtix_account": "", + "hkticketing_account": "", + "kham_account": "", + "ticket_account": "", + "udn_account": "", + "ticketplus_account": "", + "facebook_password": "", + "kktix_password": "", + "fami_password": "", + "urbtix_password": "", + "cityline_password": "", + "hkticketing_password": "", + "kham_password": "", + "ticket_password": "", + "udn_password": "", + "ticketplus_password": "", + "disable_adjacent_seat": false, + "hide_some_image": true, + "block_facebook_network": false, + "headless": false, + "verbose": false, + "auto_guess_options": true, + "user_guess_string": "", + "remote_url": "\"http://127.0.0.1:16888/\"", + "auto_reload_page_interval": 0.1, + "proxy_server_port": "" + } +} \ No newline at end of file diff --git a/settings.py b/settings.py index a317b0c..d3ded98 100644 --- a/settings.py +++ b/settings.py @@ -38,7 +38,7 @@ try: except Exception as exc: pass -CONST_APP_VERSION = "MaxBot (2024.01.07)" +CONST_APP_VERSION = "MaxBot (2024.01.08)" CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt" CONST_MAXBOT_CONFIG_FILE = "settings.json" @@ -994,16 +994,18 @@ def btn_save_act(language_code, slience_mode=False): if not file_to_save is None: if len(file_to_save) > 0: print("save as to:", file_to_save) - with open(file_to_save, 'w') as outfile: - json.dump(config_dict, outfile) + save_json(config_dict, file_to_save) else: # slience - with open(config_filepath, 'w') as outfile: - json.dump(config_dict, outfile) - + save_json(config_dict, config_filepath) return is_all_data_correct +def save_json(config_dict, target_path): + json_str = json.dumps(config_dict, indent=4) + with open(target_path, 'w') as outfile: + outfile.write(json_str) + def btn_run_clicked(language_code): print('run button pressed.') Root_Dir = "" diff --git a/webdriver/Maxbotplus_1.0.0/data/settings.json b/webdriver/Maxbotplus_1.0.0/data/settings.json index 2f45fd1..6aaaf8d 100644 --- a/webdriver/Maxbotplus_1.0.0/data/settings.json +++ b/webdriver/Maxbotplus_1.0.0/data/settings.json @@ -1 +1 @@ -{"homepage": "https://tixcraft.com", "browser": "chrome", "language": "\u7e41\u9ad4\u4e2d\u6587", "ticket_number": 2, "ocr_captcha": {"enable": true, "beta": true, "force_submit": true, "image_source": "canvas"}, "webdriver_type": "undetected_chromedriver", "date_auto_select": {"enable": true, "date_keyword": "", "mode": "random"}, "area_auto_select": {"enable": true, "mode": "random", "area_keyword": ""}, "keyword_exclude": "\"\u8f2a\u6905\",\"\u8eab\u969c\",\"\u8eab\u5fc3 \u969c\u7919\",\"Restricted View\",\"\u71c8\u67f1\u906e\u853d\",\"\u8996\u7dda\u4e0d\u5b8c\u6574\"", "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true}, "tixcraft": {"pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true}, "advanced": {"play_captcha_sound": {"enable": true, "filename": "ding-dong.wav"}, "tixcraft_sid": "", "ibonqware": "", "facebook_account": "", "kktix_account": "", "fami_account": "", "cityline_account": "", "urbtix_account": "", "hkticketing_account": "", "kham_account": "", "ticket_account": "", "udn_account": "", "ticketplus_account": "", "facebook_password": "", "kktix_password": "", "fami_password": "", "urbtix_password": "", "cityline_password": "", "hkticketing_password": "", "kham_password": "", "ticket_password": "", "udn_password": "", "ticketplus_password": "", "disable_adjacent_seat": false, "hide_some_image": false, "block_facebook_network": false, "headless": false, "verbose": false, "auto_guess_options": true, "user_guess_string": "", "remote_url": "\"http://127.0.0.1:16888/\"", "auto_reload_page_interval": 0.1, "proxy_server_port": ""}} \ No newline at end of file +{"homepage": "https://tixcraft.com", "browser": "chrome", "language": "\u7e41\u9ad4\u4e2d\u6587", "ticket_number": 2, "ocr_captcha": {"enable": true, "beta": true, "force_submit": true, "image_source": "canvas"}, "webdriver_type": "undetected_chromedriver", "date_auto_select": {"enable": true, "date_keyword": "", "mode": "random"}, "area_auto_select": {"enable": true, "mode": "random", "area_keyword": ""}, "keyword_exclude": "\"\u8f2a\u6905\",\"\u8eab\u969c\",\"\u8eab\u5fc3 \u969c\u7919\",\"Restricted View\",\"\u71c8\u67f1\u906e\u853d\",\"\u8996\u7dda\u4e0d\u5b8c\u6574\"", "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true}, "tixcraft": {"pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true}, "advanced": {"play_captcha_sound": {"enable": true, "filename": "ding-dong.wav"}, "tixcraft_sid": "", "ibonqware": "", "facebook_account": "", "kktix_account": "", "fami_account": "", "cityline_account": "", "urbtix_account": "", "hkticketing_account": "", "kham_account": "", "ticket_account": "", "udn_account": "", "ticketplus_account": "", "facebook_password": "", "kktix_password": "", "fami_password": "", "urbtix_password": "", "cityline_password": "", "hkticketing_password": "", "kham_password": "", "ticket_password": "", "udn_password": "", "ticketplus_password": "", "disable_adjacent_seat": false, "hide_some_image": true, "block_facebook_network": false, "headless": false, "verbose": false, "auto_guess_options": true, "user_guess_string": "", "remote_url": "\"http://127.0.0.1:16888/\"", "auto_reload_page_interval": 0.1, "proxy_server_port": ""}} \ No newline at end of file diff --git a/webdriver/Maxbotplus_1.0.0/js/tixcraft_ticket.js b/webdriver/Maxbotplus_1.0.0/js/tixcraft_ticket.js index e245fea..d4654c3 100644 --- a/webdriver/Maxbotplus_1.0.0/js/tixcraft_ticket.js +++ b/webdriver/Maxbotplus_1.0.0/js/tixcraft_ticket.js @@ -139,9 +139,20 @@ function get_ocr_image() return image_data; } +var last_captcha_answer=""; chrome.runtime.onMessage.addListener((message) => { //console.log('sent from background', message); - tixcraft_set_ocr_answer(message.answer); + if(message.answer.length==4) { + tixcraft_set_ocr_answer(message.answer); + last_captcha_answer=message.answer; + } else { + // renew captcha. + if(last_captcha_answer!=message.answer) { + last_captcha_answer=message.answer; + console.log("renew captcha"); + $('#TicketForm_verifyCode').click(); + } + } }); function tixcraft_set_ocr_answer(answer)