From b150bd317798e2121c3bf829a4e6e3b456e8f764 Mon Sep 17 00:00:00 2001 From: CHUN YU YAO Date: Thu, 23 Feb 2023 00:05:44 +0800 Subject: [PATCH] 2023-02-22 support headless mode. --- chrome_tixcraft.py | 121 +++++++++++++++++++++++++++++++-------------- settings.json | 2 +- settings.py | 59 +++++++++++++++++++--- 3 files changed, 138 insertions(+), 44 deletions(-) diff --git a/chrome_tixcraft.py b/chrome_tixcraft.py index 097fe3a..ff5be4b 100644 --- a/chrome_tixcraft.py +++ b/chrome_tixcraft.py @@ -47,10 +47,12 @@ try: except Exception as exc: pass +import webbrowser + import ssl ssl._create_default_https_context = ssl._create_unverified_context -CONST_APP_VERSION = u"MaxBot (2023.02.21)" +CONST_APP_VERSION = u"MaxBot (2023.02.22)" CONST_HOMEPAGE_DEFAULT = "https://tixcraft.com" URL_GOOGLE_OAUTH = 'https://accounts.google.com/o/oauth2/v2/auth/oauthchooseaccount?redirect_uri=https%3A%2F%2Fdevelopers.google.com%2Foauthplayground&prompt=consent&response_type=code&client_id=407408718192.apps.googleusercontent.com&scope=email&access_type=offline&flowName=GeneralOAuthFlow' @@ -107,6 +109,19 @@ def get_config_dict(): if os.path.isfile(config_filepath): with open(config_filepath) as json_data: config_dict = json.load(json_data) + + # special case for headless. + is_headless_enable = False + if config_dict["advanced"]["headless"]: + # for tixcraft headless. + if len(config_dict["advanced"]["tixcraft_sid"]) > 1: + is_headless_enable = True + else: + print("If you are runnig headless mode on tixcraft, you need input your cookie SID.") + + if is_headless_enable: + config_dict["ocr_captcha"]["enable"] = True + config_dict["ocr_captcha"]["force_submit"] = True return config_dict def format_keyword_string(keyword): @@ -154,7 +169,7 @@ def get_chromedriver_path(webdriver_path): chromedriver_path = os.path.join(webdriver_path,"chromedriver.exe") return chromedriver_path -def get_chrome_options(webdriver_path, adblock_plus_enable, browser="chrome"): +def get_chrome_options(webdriver_path, adblock_plus_enable, browser="chrome", headless = False): chrome_options = webdriver.ChromeOptions() if browser=="edge": chrome_options = webdriver.EdgeOptions() @@ -170,7 +185,8 @@ def get_chrome_options(webdriver_path, adblock_plus_enable, browser="chrome"): chrome_options.add_extension(no_google_analytics_path) if os.path.exists(no_ad_path): chrome_options.add_extension(no_ad_path) - + if headless: + chrome_options.add_argument('--headless') chrome_options.add_argument('--disable-features=TranslateUI') chrome_options.add_argument('--disable-translate') chrome_options.add_argument('--lang=zh-TW') @@ -195,10 +211,10 @@ def get_chrome_options(webdriver_path, adblock_plus_enable, browser="chrome"): return chrome_options, caps -def load_chromdriver_normal(webdriver_path, driver_type, adblock_plus_enable): +def load_chromdriver_normal(webdriver_path, driver_type, adblock_plus_enable, headless): chromedriver_path = get_chromedriver_path(webdriver_path) chrome_service = Service(chromedriver_path) - chrome_options, caps = get_chrome_options(webdriver_path, adblock_plus_enable) + chrome_options, caps = get_chrome_options(webdriver_path, adblock_plus_enable, headless=headless) driver = None try: # method 6: Selenium Stealth @@ -229,7 +245,7 @@ def load_chromdriver_normal(webdriver_path, driver_type, adblock_plus_enable): return driver -def load_chromdriver_uc(webdriver_path, adblock_plus_enable): +def load_chromdriver_uc(webdriver_path, adblock_plus_enable, headless): import undetected_chromedriver as uc chromedriver_path = get_chromedriver_path(webdriver_path) @@ -251,6 +267,8 @@ def load_chromdriver_uc(webdriver_path, adblock_plus_enable): if len(load_extension_path) > 0: options.add_argument('--load-extension=' + load_extension_path[1:]) + if headless: + options.add_argument('--headless') options.add_argument('--disable-features=TranslateUI') options.add_argument('--disable-translate') options.add_argument('--lang=zh-TW') @@ -438,11 +456,12 @@ def get_driver_by_config(config_dict): adblock_plus_enable = config_dict["advanced"]["adblock_plus_enable"] print("adblock_plus_enable:", adblock_plus_enable) + headless = config_dict["advanced"]["headless"] if browser == "chrome": # method 6: Selenium Stealth if driver_type != CONST_WEBDRIVER_TYPE_UC: - driver = load_chromdriver_normal(webdriver_path, driver_type, adblock_plus_enable) + driver = load_chromdriver_normal(webdriver_path, driver_type, adblock_plus_enable, headless) else: # method 5: uc # multiprocessing not work bug. @@ -450,7 +469,7 @@ def get_driver_by_config(config_dict): if hasattr(sys, 'frozen'): from multiprocessing import freeze_support freeze_support() - driver = load_chromdriver_uc(webdriver_path, adblock_plus_enable) + driver = load_chromdriver_uc(webdriver_path, adblock_plus_enable, headless) if browser == "firefox": # default os is linux/mac @@ -482,7 +501,7 @@ def get_driver_by_config(config_dict): chromedriver_path = os.path.join(webdriver_path,"msedgedriver.exe") webdriver_service = Service(chromedriver_path) - chrome_options, caps = get_chrome_options(webdriver_path, adblock_plus_enable, browser="edge") + chrome_options, caps = get_chrome_options(webdriver_path, adblock_plus_enable, browser="edge", headless=headless) driver = None try: @@ -556,6 +575,22 @@ def get_driver_by_config(config_dict): pass driver.get(homepage) + + tixcraft_family = False + if 'tixcraft.com' in homepage: + tixcraft_family = True + + if 'indievox.com' in homepage: + tixcraft_family = True + + if tixcraft_family: + if len(config_dict["advanced"]["tixcraft_sid"]) > 1: + for i in range(5): + time.sleep(1.0) + tixcraft_home_close_window(driver) + tixcraft_sid = decryptMe(config_dict["advanced"]["tixcraft_sid"]) + driver.delete_cookie("SID") + driver.add_cookie({"name":"SID", "value": tixcraft_sid, "path" : "/", "secure":True}) except WebDriverException as exce2: print('oh no not again, WebDriverException') print('WebDriverException:', exce2) @@ -1096,7 +1131,7 @@ def tixcraft_home_close_window(driver): if accept_all_cookies_btn is not None: is_visible = False try: - if accept_all_cookies_btn.is_enabled() and accept_all_cookies_btn.is_displayed(): + if accept_all_cookies_btn.is_enabled(): is_visible = True except Exception as exc: pass @@ -1912,7 +1947,7 @@ def tixcraft_toast(driver, message): except Exception as exc: print("find toast element fail") -def tixcraft_keyin_captcha_code(driver, answer = "", auto_submit = False): +def tixcraft_keyin_captcha_code(driver, answer = "", auto_submit = False): is_verifyCode_editing = False is_form_sumbited = False @@ -5620,12 +5655,11 @@ def list_all_cookies(driver): cookies_dict[cookie['name']] = cookie['value'] print(cookies_dict) -def tixcraft_main(driver, url, config_dict, answer_index, is_verifyCode_editing, ocr, Captcha_Browser): +def tixcraft_main(driver, url, config_dict, tixcraft_dict, ocr, Captcha_Browser): home_url_list = ['https://tixcraft.com/','https://www.tixcraft.com/','https://indievox.com/','https://www.indievox.com/','https://teamear.tixcraft.com/activity'] for each_url in home_url_list: if each_url == url: tixcraft_home_close_window(driver) - if config_dict["ocr_captcha"]["enable"]: domain_name = url.split('/')[2] #PS: need set cookies once, if user change domain. @@ -5653,21 +5687,31 @@ def tixcraft_main(driver, url, config_dict, answer_index, is_verifyCode_editing, if '/ticket/verify/' in url: presale_code = config_dict["tixcraft"]["presale_code"] presale_code_delimiter = config_dict["tixcraft"]["presale_code_delimiter"] - answer_index = tixcraft_verify(driver, presale_code, presale_code_delimiter, answer_index) + tixcraft_dict["answer_index"] = tixcraft_verify(driver, presale_code, presale_code_delimiter, tixcraft_dict["answer_index"]) else: - answer_index = -1 + tixcraft_dict["answer_index"] = -1 # main app, to select ticket number. if '/ticket/ticket/' in url: - if not is_verifyCode_editing: + if not tixcraft_dict["is_verifyCode_editing"]: domain_name = url.split('/')[2] - is_verifyCode_editing = tixcraft_ticket_main(driver, config_dict, ocr, Captcha_Browser, domain_name) + tixcraft_dict["is_verifyCode_editing"] = tixcraft_ticket_main(driver, config_dict, ocr, Captcha_Browser, domain_name) else: - is_verifyCode_editing = False + tixcraft_dict["is_verifyCode_editing"] = False - return answer_index, is_verifyCode_editing + if '/ticket/checkout' in url: + if not tixcraft_dict["is_popup_checkout"]: + domain_name = url.split('/')[2] + checkout_url = "https://%s/ticket/checkout" % (domain_name) + print("搶票成功, 請前往該帳號訂單查看: %s" % (checkout_url)) + webbrowser.open_new(checkout_url) + tixcraft_dict["is_popup_checkout"] = True + else: + tixcraft_dict["is_popup_checkout"] = False -def kktix_main(driver, url, config_dict, answer_index, kktix_register_status_last): + return tixcraft_dict + +def kktix_main(driver, url, config_dict, kktix_dict): auto_press_next_step_button = config_dict["kktix"]["auto_press_next_step_button"] kktix_account = config_dict["advanced"]["kktix_account"] @@ -5680,7 +5724,7 @@ def kktix_main(driver, url, config_dict, answer_index, kktix_register_status_las if not is_url_contain_sign_in: if '/registrations/new' in url: - answer_index, kktix_register_status_last = kktix_reg_new(driver, url, answer_index, kktix_register_status_last, config_dict) + kktix_dict["answer_index"], kktix_dict["kktix_register_status_last"] = kktix_reg_new(driver, url, kktix_dict["answer_index"], kktix_dict["kktix_register_status_last"], config_dict) else: is_event_page = False if '/events/' in url: @@ -5694,9 +5738,9 @@ def kktix_main(driver, url, config_dict, answer_index, kktix_register_status_las #print("should press next here.") kktix_events_press_next_button(driver) - answer_index = -1 - kktix_register_status_last = None - return answer_index, kktix_register_status_last + kktix_dict["answer_index"] = -1 + kktix_dict["kktix_register_status_last"] = None + return kktix_dict def famiticket_main(driver, url, config_dict): try: @@ -5997,10 +6041,10 @@ def ibon_main(driver, url, config_dict, answer_index): #auto_guess_options = config_dict["kktix"]["auto_guess_options"] auto_guess_options = True if auto_guess_options: - #answer_index = ibon_verification_question(driver, answer_index, config_dict) + #ibon_dict["answer_index"] = ibon_verification_question(driver, ibon_dict["answer_index"], config_dict) pass else: - answer_index = -1 + ibon_dict["answer_index"] = -1 # https://orders.ibon.com.tw/application/UTK02/UTK0201_000.aspx?PERFORMANCE_ID=0000 if '/application/UTK02/' in url and '.aspx?PERFORMANCE_ID=' in url: @@ -6021,7 +6065,7 @@ def ibon_main(driver, url, config_dict, answer_index): # step 1: select area. ibon_performance(driver, config_dict) - return answer_index + return ibon_dict def hkticketing_home(driver): show_debug_message = True # debug. @@ -7758,11 +7802,18 @@ def main(): last_url = "" # for tixcraft - is_verifyCode_editing = False + tixcraft_dict = {} + tixcraft_dict["answer_index"]=-1 + tixcraft_dict["is_verifyCode_editing"] = False + tixcraft_dict["is_popup_checkout"] = False # for kktix - answer_index = -1 - kktix_register_status_last = None + kktix_dict = {} + kktix_dict["answer_index"]=-1 + kktix_dict["kktix_register_status_last"] = None + + ibon_dict = {} + ibon_dict["answer_index"]=-1 DISCONNECTED_MSG = ': target window already closed' @@ -7907,10 +7958,6 @@ def main(): print(url) last_url = url - # for Max's manuall test. - if '/Downloads/varify.html' in url: - answer_index = tixcraft_verify(driver, "", "", answer_index) - tixcraft_family = False if 'tixcraft.com' in url: tixcraft_family = True @@ -7919,17 +7966,17 @@ def main(): tixcraft_family = True if tixcraft_family: - answer_index, is_verifyCode_editing = tixcraft_main(driver, url, config_dict, answer_index, is_verifyCode_editing, ocr, Captcha_Browser) + tixcraft_dict = tixcraft_main(driver, url, config_dict, tixcraft_dict, ocr, Captcha_Browser) # for kktix.cc and kktix.com if 'kktix.c' in url: - answer_index, kktix_register_status_last = kktix_main(driver, url, config_dict, answer_index, kktix_register_status_last) + kktix_dict = kktix_main(driver, url, config_dict, kktix_dict) if 'famiticket.com' in url: famiticket_main(driver, url, config_dict) if 'ibon.com' in url: - answer_index = ibon_main(driver, url, config_dict, answer_index) + ibon_dict = ibon_main(driver, url, config_dict, ibon_dict) if 'kham.com' in url: kham_main(driver, url, config_dict, ocr, Captcha_Browser) diff --git a/settings.json b/settings.json index bc858d4..c296ce5 100644 --- a/settings.json +++ b/settings.json @@ -1 +1 @@ -{"homepage": "https://tixcraft.com", "browser": "chrome", "language": "\u7e41\u9ad4\u4e2d\u6587", "ticket_number": 2, "pass_1_seat_remaining": true, "auto_check_agree": true, "ocr_captcha": {"enable": true, "force_submit": false, "image_source": "canvas"}, "webdriver_type": "undetected_chromedriver", "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true, "area_mode": "from top to bottom", "area_keyword_1": "", "area_keyword_1_and": "", "area_keyword_2": "", "area_keyword_2_and": "", "area_keyword_2_enable": true, "auto_guess_options": true, "user_guess_string": ""}, "tixcraft": {"date_auto_select": {"enable": true, "date_keyword": "", "mode": "from top to bottom"}, "area_auto_select": {"enable": true, "area_keyword_1": "", "area_keyword_2": "", "area_keyword_3": "", "area_keyword_4": "", "area_keyword_2_enable": true, "area_keyword_3_enable": true, "area_keyword_4_enable": true, "mode": "from top to bottom"}, "pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true, "presale_code": "", "presale_code_delimiter": ""}, "advanced": {"play_captcha_sound": {"enable": true, "filename": "ding-dong.wav"}, "facebook_account": "", "kktix_account": "", "cityline_account": "", "urbtix_account": "", "hkticketing_account": "", "kham_account": "", "facebook_password": "", "kktix_password": "", "cityline_password": "", "urbtix_password": "", "hkticketing_password": "", "kham_password": "", "adblock_plus_enable": false, "open_google_oauth_url": false}, "debug": false} \ No newline at end of file +{"homepage": "https://tixcraft.com", "browser": "chrome", "language": "\u7e41\u9ad4\u4e2d\u6587", "ticket_number": 2, "pass_1_seat_remaining": true, "auto_check_agree": true, "ocr_captcha": {"enable": true, "force_submit": false, "image_source": "canvas"}, "webdriver_type": "undetected_chromedriver", "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true, "area_mode": "from top to bottom", "area_keyword_1": "", "area_keyword_1_and": "", "area_keyword_2": "", "area_keyword_2_and": "", "area_keyword_2_enable": true, "auto_guess_options": true, "user_guess_string": ""}, "tixcraft": {"date_auto_select": {"enable": true, "date_keyword": "", "mode": "from top to bottom"}, "area_auto_select": {"enable": true, "area_keyword_1": "", "area_keyword_2": "", "area_keyword_3": "", "area_keyword_4": "", "area_keyword_2_enable": true, "area_keyword_3_enable": true, "area_keyword_4_enable": true, "mode": "from top to bottom"}, "pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true, "presale_code": "", "presale_code_delimiter": ""}, "advanced": {"play_captcha_sound": {"enable": true, "filename": "ding-dong.wav"}, "tixcraft_sid": "", "facebook_account": "", "kktix_account": "", "cityline_account": "", "urbtix_account": "", "hkticketing_account": "", "kham_account": "", "facebook_password": "", "kktix_password": "", "cityline_password": "", "urbtix_password": "", "hkticketing_password": "", "kham_password": "", "adblock_plus_enable": false, "open_google_oauth_url": false, "headless": false}, "debug": false} \ No newline at end of file diff --git a/settings.py b/settings.py index cf22c89..3fca212 100644 --- a/settings.py +++ b/settings.py @@ -20,7 +20,7 @@ import webbrowser import pyperclip import base64 -CONST_APP_VERSION = u"MaxBot (2023.02.21)" +CONST_APP_VERSION = u"MaxBot (2023.02.22)" CONST_FROM_TOP_TO_BOTTOM = u"from top to bottom" CONST_FROM_BOTTOM_TO_TOP = u"from bottom to top" @@ -29,12 +29,12 @@ CONST_SELECT_ORDER_DEFAULT = CONST_FROM_TOP_TO_BOTTOM CONST_SELECT_OPTIONS_DEFAULT = (CONST_FROM_TOP_TO_BOTTOM, CONST_FROM_BOTTOM_TO_TOP, CONST_RANDOM) CONST_SELECT_OPTIONS_ARRAY = [CONST_FROM_TOP_TO_BOTTOM, CONST_FROM_BOTTOM_TO_TOP, CONST_RANDOM] CONST_ADBLOCK_PLUS_ADVANCED_FILTER_DEFAULT = '''tixcraft.com###topAlert -tixcraft.com##.col-md-7.col-xs-12.mg-top +tixcraft.com##.col-md-7.col-xs-12.mgt-16.text-center +tixcraft.com##.col-md-7.col-xs-12.mgt-16.mx-auto tixcraft.com##.topBar.alert-box.emergency tixcraft.com##.footer.clearfix -tixcraft.com##.row.process-wizard.process-wizard-info -tixcraft.com##.nav-line -tixcraft.com##.page-info.row.line-btm.mg-0''' +tixcraft.com##.page-info.row.line-btm.mg-0 +tixcraft.com##.row.justify-content-start.navbar-location''' CONST_CAPTCHA_SOUND_FILENAME_DEFAULT = "ding-dong.wav" CONST_HOMEPAGE_DEFAULT = "https://tixcraft.com" @@ -92,6 +92,7 @@ def load_translate(): en_us["ocr_captcha_force_submit"] = 'Away from keyboard' en_us["ocr_captcha_image_source"] = 'OCR image source' en_us["webdriver_type"] = 'WebDriver type' + en_us["headless"] = 'Headless mode' en_us["preference"] = 'Preference' en_us["advanced"] = 'Advanced' @@ -105,6 +106,7 @@ def load_translate(): en_us["restore_defaults"] = 'Restore Defaults' en_us["done"] = 'Done' + en_us["tixcraft_sid"] = 'Tixcraft cookie SID' en_us["facebook_account"] = 'Facebook account' en_us["kktix_account"] = 'KKTIX account' en_us["cityline_account"] = 'cityline account' @@ -167,6 +169,7 @@ def load_translate(): zh_tw["ocr_captcha_force_submit"] = '掛機模式' zh_tw["ocr_captcha_image_source"] = 'OCR圖片取得方式' zh_tw["webdriver_type"] = 'WebDriver類別' + zh_tw["headless"] = '無圖形界面模式' zh_tw["preference"] = '偏好設定' zh_tw["advanced"] = '進階設定' @@ -180,6 +183,7 @@ def load_translate(): zh_tw["restore_defaults"] = '恢復預設值' zh_tw["done"] = '完成' + zh_tw["tixcraft_sid"] = 'Tixcraft cookie SID' zh_tw["facebook_account"] = 'Facebook 帳號' zh_tw["kktix_account"] = 'KKTIX 帳號' zh_tw["cityline_account"] = 'cityline 帳號' @@ -242,6 +246,7 @@ def load_translate(): zh_cn["ocr_captcha_force_submit"] = '挂机模式' zh_cn["ocr_captcha_image_source"] = 'OCR图像源' zh_cn["webdriver_type"] = 'WebDriver类别' + zh_cn["headless"] = '无图形界面模式' zh_cn["preference"] = '偏好设定' zh_cn["advanced"] = '進階設定' @@ -256,6 +261,7 @@ def load_translate(): zh_cn["restore_defaults"] = '恢复默认值' zh_cn["done"] = '完成' + zh_cn["tixcraft_sid"] = 'Tixcraft cookie SID' zh_cn["facebook_account"] = 'Facebook 帐号' zh_cn["kktix_account"] = 'KKTIX 帐号' zh_cn["cityline_account"] = 'cityline 帐号' @@ -318,6 +324,7 @@ def load_translate(): ja_jp["ocr_captcha_force_submit"] = 'キーボードから離れて' ja_jp["ocr_captcha_image_source"] = 'OCR 画像ソース' ja_jp["webdriver_type"] = 'WebDriverタイプ' + ja_jp["headless"] = 'ヘッドレスモード' ja_jp["preference"] = '設定' ja_jp["advanced"] = '高度な設定' @@ -331,6 +338,7 @@ def load_translate(): ja_jp["restore_defaults"] = 'デフォルトに戻す' ja_jp["done"] = '終わり' + ja_jp["tixcraft_sid"] = 'Tixcraft cookie SID' ja_jp["facebook_account"] = 'Facebookのアカウント' ja_jp["kktix_account"] = 'KKTIXのアカウント' ja_jp["cityline_account"] = 'citylineのアカウント' @@ -446,6 +454,7 @@ def get_default_config(): config_dict["advanced"]["play_captcha_sound"]["enable"] = True config_dict["advanced"]["play_captcha_sound"]["filename"] = CONST_CAPTCHA_SOUND_FILENAME_DEFAULT + config_dict["advanced"]["tixcraft_sid"] = "" config_dict["advanced"]["facebook_account"] = "" config_dict["advanced"]["kktix_account"] = "" config_dict["advanced"]["cityline_account"] = "" @@ -462,6 +471,7 @@ def get_default_config(): config_dict["advanced"]["adblock_plus_enable"] = False config_dict["advanced"]["open_google_oauth_url"] = False + config_dict["advanced"]["headless"] = False config_dict['debug']=False @@ -539,6 +549,7 @@ def btn_save_act(language_code, slience_mode=False): global txt_presale_code global txt_presale_code_delimiter + global txt_tixcraft_sid global txt_facebook_account global txt_kktix_account global txt_cityline_account @@ -559,6 +570,7 @@ def btn_save_act(language_code, slience_mode=False): global chk_state_ocr_captcha global chk_state_ocr_captcha_force_submit global chk_state_google_oauth + global chk_state_headless global combo_ocr_captcha_image_source global combo_webdriver_type @@ -638,6 +650,7 @@ def btn_save_act(language_code, slience_mode=False): config_dict["advanced"]["play_captcha_sound"]["enable"] = bool(chk_state_play_captcha_sound.get()) config_dict["advanced"]["play_captcha_sound"]["filename"] = txt_captcha_sound_filename.get().strip() + config_dict["advanced"]["tixcraft_sid"] = txt_tixcraft_sid.get().strip() config_dict["advanced"]["facebook_account"] = txt_facebook_account.get().strip() config_dict["advanced"]["kktix_account"] = txt_kktix_account.get().strip() config_dict["advanced"]["cityline_account"] = txt_cityline_account.get().strip() @@ -652,6 +665,7 @@ def btn_save_act(language_code, slience_mode=False): config_dict["advanced"]["hkticketing_password"] = txt_hkticketing_password.get().strip() config_dict["advanced"]["kham_password"] = txt_kham_password.get().strip() + config_dict["advanced"]["tixcraft_sid"] = encryptMe(config_dict["advanced"]["tixcraft_sid"]) config_dict["advanced"]["facebook_password"] = encryptMe(config_dict["advanced"]["facebook_password"]) config_dict["advanced"]["kktix_password"] = encryptMe(config_dict["advanced"]["kktix_password"]) config_dict["advanced"]["cityline_password"] = encryptMe(config_dict["advanced"]["cityline_password"]) @@ -667,6 +681,7 @@ def btn_save_act(language_code, slience_mode=False): config_dict["ocr_captcha"]["force_submit"] = bool(chk_state_ocr_captcha_force_submit.get()) config_dict["ocr_captcha"]["image_source"] = combo_ocr_captcha_image_source.get().strip() config_dict["webdriver_type"] = combo_webdriver_type.get().strip() + config_dict["advanced"]["headless"] = bool(chk_state_headless.get()) # save config. if is_all_data_correct: @@ -831,6 +846,7 @@ def applyNewLanguage(): global lbl_ocr_captcha_force_submit global lbl_ocr_captcha_image_source global lbl_webdriver_type + global lbl_headless # for checkbox global chk_pass_1_seat_remaining @@ -848,6 +864,7 @@ def applyNewLanguage(): global chk_ocr_captcha global chk_ocr_captcha_force_submit global chk_google_oauth + global chk_headless global chk_kktix_area_keyword_2_enable global chk_area_keyword_2_enable @@ -901,6 +918,7 @@ def applyNewLanguage(): lbl_ocr_captcha_image_source.config(text=translate[language_code]["ocr_captcha_image_source"]) lbl_webdriver_type.config(text=translate[language_code]["webdriver_type"]) lbl_google_oauth.config(text=translate[language_code]["open_google_oauth_url"]) + lbl_headless.config(text=translate[language_code]["headless"]) chk_pass_1_seat_remaining.config(text=translate[language_code]["enable"]) chk_auto_check_agree.config(text=translate[language_code]["enable"]) @@ -916,6 +934,7 @@ def applyNewLanguage(): chk_ocr_captcha.config(text=translate[language_code]["enable"]) chk_ocr_captcha_force_submit.config(text=translate[language_code]["enable"]) chk_google_oauth.config(text=translate[language_code]["enable"]) + chk_headless.config(text=translate[language_code]["enable"]) chk_kktix_area_keyword_2_enable.config(text=translate[language_code]["enable"]) chk_area_keyword_2_enable.config(text=translate[language_code]["enable"]) @@ -927,6 +946,7 @@ def applyNewLanguage(): tabControl.tab(2, text=translate[language_code]["autofill"]) tabControl.tab(3, text=translate[language_code]["about"]) + global lbl_tixcraft_sid global lbl_facebook_account global lbl_kktix_account global lbl_cityline_account @@ -945,6 +965,8 @@ def applyNewLanguage(): global lbl_play_captcha_sound global lbl_captcha_sound_filename + + lbl_tixcraft_sid.config(text=translate[language_code]["tixcraft_sid"]) lbl_facebook_account.config(text=translate[language_code]["facebook_account"]) lbl_kktix_account.config(text=translate[language_code]["kktix_account"]) lbl_cityline_account.config(text=translate[language_code]["cityline_account"]) @@ -1264,7 +1286,7 @@ def PreferenctTab(root, config_dict, language_code, UI_PADDING_X): lbl_homepage.grid(column=0, row=group_row_count, sticky = E) global combo_homepage - combo_homepage = ttk.Combobox(frame_group_header, state="readonly") + combo_homepage = ttk.Combobox(frame_group_header) combo_homepage['values']= ["https://kktix.com" ,"https://tixcraft.com (拓元)" ,"https://teamear.tixcraft.com/ (添翼)" @@ -1915,6 +1937,20 @@ def AdvancedTab(root, config_dict, language_code, UI_PADDING_X): chk_google_oauth = Checkbutton(frame_group_header, text=translate[language_code]['enable'], variable=chk_state_google_oauth) chk_google_oauth.grid(column=1, row=group_row_count, sticky = W) + group_row_count+=1 + + global lbl_headless + lbl_headless = Label(frame_group_header, text=translate[language_code]['headless']) + lbl_headless.grid(column=0, row=group_row_count, sticky = E) + + global chk_state_headless + chk_state_headless = BooleanVar() + chk_state_headless.set(config_dict['advanced']["headless"]) + + global chk_headless + chk_headless = Checkbutton(frame_group_header, text=translate[language_code]['enable'], variable=chk_state_headless) + chk_headless.grid(column=1, row=group_row_count, sticky = W) + frame_group_header.grid(column=0, row=row_count, padx=UI_PADDING_X) def AutofillTab(root, config_dict, language_code, UI_PADDING_X): @@ -1923,6 +1959,17 @@ def AutofillTab(root, config_dict, language_code, UI_PADDING_X): frame_group_header = Frame(root) group_row_count = 0 + global lbl_tixcraft_sid + lbl_tixcraft_sid = Label(frame_group_header, text=translate[language_code]['tixcraft_sid']) + lbl_tixcraft_sid.grid(column=0, row=group_row_count, sticky = E) + + global txt_tixcraft_sid + txt_tixcraft_sid_value = StringVar(frame_group_header, value=decryptMe(config_dict["advanced"]["tixcraft_sid"].strip())) + txt_tixcraft_sid = Entry(frame_group_header, width=20, textvariable = txt_tixcraft_sid_value, show="*") + txt_tixcraft_sid.grid(column=1, row=group_row_count, sticky = W) + + group_row_count +=1 + global lbl_facebook_account lbl_facebook_account = Label(frame_group_header, text=translate[language_code]['facebook_account']) lbl_facebook_account.grid(column=0, row=group_row_count, sticky = E)