From dd53d0520989e1ed64786032a1c0b2b28d17b06a Mon Sep 17 00:00:00 2001 From: unknown <2303063@ad.nchc.org.tw> Date: Wed, 10 Jan 2024 10:58:03 +0800 Subject: [PATCH] 2023-01-02, update for MaxBot Plus extension. --- chrome_tixcraft.py | 17 ++-- config_launcher.py | 2 +- settings.py | 2 +- text_server.py | 2 +- webdriver/Maxbotplus_1.0.0/js/ibon_detail.js | 2 + webdriver/Maxbotplus_1.0.0/js/ibon_ticket.js | 65 ++++++++++++++ webdriver/Maxbotplus_1.0.0/js/kham_date.js | 3 + webdriver/Maxbotplus_1.0.0/js/kham_home.js | 5 ++ webdriver/Maxbotplus_1.0.0/js/kktix_home.js | 5 ++ webdriver/Maxbotplus_1.0.0/js/ticket_home.js | 2 + webdriver/Maxbotplus_1.0.0/manifest.json | 33 ++++++- webdriver/Maxbotplus_1.0.0/options.html | 9 ++ webdriver/Maxbotplus_1.0.0/options.js | 4 + webdriver/Maxbotplus_1.0.0/rules_1.json | 94 +++++++++++++------- 14 files changed, 201 insertions(+), 44 deletions(-) create mode 100644 webdriver/Maxbotplus_1.0.0/js/ibon_detail.js create mode 100644 webdriver/Maxbotplus_1.0.0/js/ibon_ticket.js create mode 100644 webdriver/Maxbotplus_1.0.0/js/kham_home.js create mode 100644 webdriver/Maxbotplus_1.0.0/js/kktix_home.js create mode 100644 webdriver/Maxbotplus_1.0.0/js/ticket_home.js diff --git a/chrome_tixcraft.py b/chrome_tixcraft.py index 97e5b86..d8e40e8 100644 --- a/chrome_tixcraft.py +++ b/chrome_tixcraft.py @@ -54,7 +54,7 @@ import webbrowser import chromedriver_autoinstaller -CONST_APP_VERSION = "MaxBot (2024.01.01)" +CONST_APP_VERSION = "MaxBot (2024.01.02)" CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt" @@ -871,6 +871,7 @@ def get_driver_by_config(config_dict): ,'*googletagservices.*' ,'*play.google.com/*' ,'*.googlesyndication.com/*' + ,'*cdn.cookielaw.org/*' ,'*fundingchoicesmessages.google.com/*' ,'*.doubleclick.net/*' ,'*.rollbar.com/*' @@ -8141,7 +8142,8 @@ def urbtix_main(driver, url, config_dict): pass pass # 刷太快, 會被封IP? - time.sleep(config_dict["advanced"]["auto_reload_page_interval"]) + if config_dict["advanced"]["auto_reload_page_interval"] > 0: + time.sleep(config_dict["advanced"]["auto_reload_page_interval"]) if '/logout?' in url: try: @@ -8253,7 +8255,8 @@ def cityline_auto_retry_access(driver, config_dict): pass # 刷太快, 會被封IP? - time.sleep(config_dict["advanced"]["auto_reload_page_interval"]) + if config_dict["advanced"]["auto_reload_page_interval"] > 0: + time.sleep(config_dict["advanced"]["auto_reload_page_interval"]) def cityline_go_venue(driver, url): url_https = url.replace("http://","https://") @@ -8638,7 +8641,7 @@ def ibon_captcha(driver, config_dict, ocr, Captcha_Browser, model_name): is_captcha_sent = False previous_answer = None last_url, is_quit_bot = get_current_url(driver) - for redo_ocr in range(999): + for redo_ocr in range(19): is_need_redo_ocr, previous_answer, is_form_sumbited = ibon_auto_ocr(driver, config_dict, ocr, away_from_keyboard_enable, previous_answer, Captcha_Browser, ocr_captcha_image_source, model_name) # TODO: must ensure the answer is corrent... @@ -9613,7 +9616,8 @@ def hkticketing_url_redirect(driver, url, config_dict): pass # 刷太快, 會被封IP? - time.sleep(config_dict["advanced"]["auto_reload_page_interval"]) + if config_dict["advanced"]["auto_reload_page_interval"] > 0: + time.sleep(config_dict["advanced"]["auto_reload_page_interval"]) if is_redirected: break @@ -9695,7 +9699,8 @@ def hkticketing_content_refresh(driver, url, config_dict): pass # 刷太快, 會被封IP? - time.sleep(config_dict["advanced"]["auto_reload_page_interval"]) + if config_dict["advanced"]["auto_reload_page_interval"] > 0: + time.sleep(config_dict["advanced"]["auto_reload_page_interval"]) return is_redirected diff --git a/config_launcher.py b/config_launcher.py index f5a1a45..b9c8337 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.01)" +CONST_APP_VERSION = "MaxBot (2024.01.02)" CONST_MAXBOT_LAUNCHER_FILE = "config_launcher.json" CONST_MAXBOT_CONFIG_FILE = "settings.json" diff --git a/settings.py b/settings.py index c51da42..335657c 100644 --- a/settings.py +++ b/settings.py @@ -34,7 +34,7 @@ import ssl ssl._create_default_https_context = ssl._create_unverified_context -CONST_APP_VERSION = "MaxBot (2024.01.01)" +CONST_APP_VERSION = "MaxBot (2024.01.02)" CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt" diff --git a/text_server.py b/text_server.py index 468e315..8750b0d 100644 --- a/text_server.py +++ b/text_server.py @@ -27,7 +27,7 @@ import pyperclip import tornado from tornado.web import Application -CONST_APP_VERSION = "MaxBot (2024.01.01)" +CONST_APP_VERSION = "MaxBot (2024.01.02)" CONST_MAXBOT_QUESTION_FILE = "MAXBOT_QUESTION.txt" diff --git a/webdriver/Maxbotplus_1.0.0/js/ibon_detail.js b/webdriver/Maxbotplus_1.0.0/js/ibon_detail.js new file mode 100644 index 0000000..780193b --- /dev/null +++ b/webdriver/Maxbotplus_1.0.0/js/ibon_detail.js @@ -0,0 +1,2 @@ +// TODO: ... +console.log("TODO: date auto click..."); \ No newline at end of file diff --git a/webdriver/Maxbotplus_1.0.0/js/ibon_ticket.js b/webdriver/Maxbotplus_1.0.0/js/ibon_ticket.js new file mode 100644 index 0000000..c59352f --- /dev/null +++ b/webdriver/Maxbotplus_1.0.0/js/ibon_ticket.js @@ -0,0 +1,65 @@ +const storage = chrome.storage.local; +var settings = null; + +$("footer").remove(); + +function assign_ticket_number(ticket_number) +{ + let $main_table = $("table.table"); + if ($main_table.length > 0) + { + console.log("found main table"); + let $ticket_options = $main_table.find("select:first option"); + if ($ticket_options.length) + { + let is_ticket_number_assign = false; + if (ticket_number > 0) + { + console.log("target ticket_number:"+ticket_number); + $ticket_options.each(function () + { + if ($(this).val() == ticket_number) + { + $(this).prop('selected', true); + is_ticket_number_assign = true; + return false; + } + } + ); + } + console.log("is_ticket_number_assign:"+is_ticket_number_assign); + if (!is_ticket_number_assign) + { + $ticket_options.last().prop('selected', true); + } + } + } +} + +function assign_adjacent_seat(flag) { + //console.log("disable_adjacent_seat flag:"+flag); + if(flag) { + $('input[type=checkbox]').each(function() { + $(this).prop('checked', true); + }); + } +} + +function focus_on_captcha() +{ + $("div.editor-box > div > input[type='text']").focus(); +} + +storage.get('settings', function (items) +{ + if (items.settings) + { + settings = items.settings; + //console.log("ticket_number:"+ settings.ticket_number); + assign_ticket_number(settings.ticket_number); + assign_adjacent_seat(settings.advanced.disable_adjacent_seat); + focus_on_captcha(); + } else { + console.log('no settings found'); + } +}); diff --git a/webdriver/Maxbotplus_1.0.0/js/kham_date.js b/webdriver/Maxbotplus_1.0.0/js/kham_date.js index cd8e975..6c96358 100644 --- a/webdriver/Maxbotplus_1.0.0/js/kham_date.js +++ b/webdriver/Maxbotplus_1.0.0/js/kham_date.js @@ -1,3 +1,6 @@ +$("div#DIV_REMARK").remove(); +$("div.footer").remove(); + $a_btn=$("#content").find("table.eventTABLE > tbody > tr > td > a > button[onclick]"); if($a_btn.length==1) { $a_btn.click(); diff --git a/webdriver/Maxbotplus_1.0.0/js/kham_home.js b/webdriver/Maxbotplus_1.0.0/js/kham_home.js new file mode 100644 index 0000000..28077bf --- /dev/null +++ b/webdriver/Maxbotplus_1.0.0/js/kham_home.js @@ -0,0 +1,5 @@ +$("div#dialog-message").remove(); +$("div#ad3").remove(); +$("div#buyTicket").remove(); +$("div#marquee").remove(); +$("div.footer").remove(); diff --git a/webdriver/Maxbotplus_1.0.0/js/kktix_home.js b/webdriver/Maxbotplus_1.0.0/js/kktix_home.js new file mode 100644 index 0000000..247e48f --- /dev/null +++ b/webdriver/Maxbotplus_1.0.0/js/kktix_home.js @@ -0,0 +1,5 @@ +$("div.headlines").remove(); +$("section.app-intro").remove(); +$("section.copywriting").remove(); +$("section.partner-venues").remove(); +$("footer").remove(); diff --git a/webdriver/Maxbotplus_1.0.0/js/ticket_home.js b/webdriver/Maxbotplus_1.0.0/js/ticket_home.js new file mode 100644 index 0000000..fd86a42 --- /dev/null +++ b/webdriver/Maxbotplus_1.0.0/js/ticket_home.js @@ -0,0 +1,2 @@ +$("#footer").remove(); +$("footer").remove(); diff --git a/webdriver/Maxbotplus_1.0.0/manifest.json b/webdriver/Maxbotplus_1.0.0/manifest.json index 789cf3d..c93d8b8 100644 --- a/webdriver/Maxbotplus_1.0.0/manifest.json +++ b/webdriver/Maxbotplus_1.0.0/manifest.json @@ -90,6 +90,11 @@ "run_at": "document_end", "js" : [ "jquery.min.js", "js/tixcraft_ticket.js" ] }, + { + "matches" : [ "https://ticket.com.tw/application/utk01/utk0101_.aspx" ], + "run_at": "document_end", + "js" : [ "jquery.min.js", "js/ticket_home.js" ] + }, { "matches" : [ "https://ticket.com.tw/application/UTK02/UTK0201_.aspx?PRODUCT_ID=*" ], "run_at": "document_end", @@ -107,6 +112,11 @@ "run_at": "document_end", "js" : [ "jquery.min.js", "js/common.js", "js/ticket_area.js" ] }, + { + "matches" : [ "https://kham.com.tw/application/utk01/UTK0101_03.aspx" ], + "run_at": "document_end", + "js" : [ "jquery.min.js", "js/kham_home.js" ] + }, { "matches" : [ "https://kham.com.tw/application/UTK02/UTK0201_.aspx?PRODUCT_ID=*" ], "run_at": "document_end", @@ -114,7 +124,9 @@ "js" : [ "jquery.min.js", "js/kham_event_home.js" ] }, { - "matches" : [ "https://kham.com.tw/application/UTK02/UTK0201_00.aspx?PRODUCT_ID=*" ], + "matches" : [ + "https://kham.com.tw/application/UTK02/UTK0201_00.aspx?PRODUCT_ID=*" + ], "run_at": "document_end", "world": "MAIN", "js" : [ "jquery.min.js", "js/kham_date.js" ] @@ -124,11 +136,21 @@ "run_at": "document_end", "js" : [ "jquery.min.js", "js/kham_area.js" ] }, + { + "matches" : [ "https://ticket.ibon.com.tw/ActivityInfo/Details/*" ], + "run_at": "document_end", + "js" : [ "jquery.min.js", "js/ibon_detail.js" ] + }, { "matches" : [ "https://orders.ibon.com.tw/application/UTK02/UTK0201_000.aspx?*" ], "run_at": "document_end", "js" : [ "jquery.min.js", "js/ibon_area.js" ] }, + { + "matches" : [ "https://orders.ibon.com.tw/application/UTK02/UTK0201_001.aspx?PERFORMANCE_ID=*PERFORMANCE_PRICE_AREA_ID=*" ], + "run_at": "document_end", + "js" : [ "jquery.min.js", "js/ibon_ticket.js" ] + }, { "matches" : [ "https://msg.cityline.com/*.html*" @@ -138,7 +160,7 @@ }, { "matches" : [ - "https://msg.cityline.com/*.html*" + "https://msg.cityline.com/*" ], "run_at": "document_end", "world": "MAIN", @@ -166,6 +188,13 @@ "run_at": "document_start", "js" : [ "jquery.min.js", "js/ticketplus_order.js"] }, + { + "matches" : [ + "https://kktix.com/" + ], + "run_at": "document_end", + "js" : [ "jquery.min.js", "js/kktix_home.js" ] + }, { "matches" : [ "https://*.kktix.cc/events/*" diff --git a/webdriver/Maxbotplus_1.0.0/options.html b/webdriver/Maxbotplus_1.0.0/options.html index 40c3c51..ea7bb82 100644 --- a/webdriver/Maxbotplus_1.0.0/options.html +++ b/webdriver/Maxbotplus_1.0.0/options.html @@ -67,6 +67,15 @@ +