2023-12-16 Maxbot extension

master
unknown 2023-12-27 14:17:40 +08:00
parent 63fa68c752
commit 51ba97f718
20 changed files with 212 additions and 77 deletions

View File

@ -54,7 +54,7 @@ import webbrowser
import chromedriver_autoinstaller
CONST_APP_VERSION = "MaxBot (2023.12.14)"
CONST_APP_VERSION = "MaxBot (2023.12.16)"
CONST_MAXBOT_CONFIG_FILE = "settings.json"
CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt"
@ -593,7 +593,17 @@ def get_uc_options(uc, config_dict, webdriver_path):
for ext in extension_list:
ext = ext.replace('.crx','')
if os.path.exists(ext):
# sync config.
if "Maxbot_" in ext:
target_path = ext
target_path = os.path.join(target_path, "data")
target_path = os.path.join(target_path, "settings.json")
#print("save as to:", target_path)
if os.path.exists(target_path):
with open(target_path, 'w') as outfile:
json.dump(config_dict, outfile)
load_extension_path += ("," + os.path.abspath(ext))
if len(load_extension_path) > 0:
print('load-extension:', load_extension_path[1:])
options.add_argument('--load-extension=' + load_extension_path[1:])
@ -2021,6 +2031,24 @@ def tixcraft_date_auto_select(driver, url, config_dict, domain_name):
if show_debug_message:
print("press button fail, try to click hyperlink.")
if "tixcraft" in domain_name:
try:
data_href = target_area.get_attribute("data-href")
if not data_href is None:
print("goto url:", data_href)
driver.get(data_href)
else:
if show_debug_message:
print("data-href not ready")
# delay 200ms to click.
#driver.set_script_timeout(0.3)
#js="""setTimeout(function(){arguments[0].click()},200);"""
#driver.execute_script(js, target_area)
except Exception as exc:
pass
# for: ticketmaster.sg
is_date_clicked = force_press_button(target_area, By.CSS_SELECTOR,'a')
@ -3180,7 +3208,6 @@ def tixcraft_auto_ocr(driver, ocr, away_from_keyboard_enable, previous_answer, C
return is_need_redo_ocr, previous_answer, is_form_sumbited
def tixcraft_ticket_main_agree(driver, config_dict):
if config_dict["auto_check_agree"]:
for i in range(3):
is_finish_checkbox_click = tixcraft_ticket_agree(driver, config_dict)
if is_finish_checkbox_click:
@ -3304,9 +3331,8 @@ def get_tixcraft_ticket_select(driver, config_dict):
return form_select
def tixcraft_ticket_main(driver, config_dict, ocr, Captcha_Browser, domain_name):
# use extension instead of selenium.
#tixcraft_ticket_main_agree(driver, config_dict)
def tixcraft_assign_ticket_number(driver, config_dict):
is_ticket_number_assigned = False
# allow agree not enable to assign ticket number.
form_select_list = None
@ -3341,20 +3367,12 @@ def tixcraft_ticket_main(driver, config_dict, ocr, Captcha_Browser, domain_name)
select_obj = None
if not form_select is None:
is_visible = False
try:
if form_select.is_enabled():
is_visible = True
except Exception as exc:
pass
if is_visible:
try:
select_obj = Select(form_select)
except Exception as exc:
pass
if not select_obj is None:
is_ticket_number_assigned = False
row_text = None
try:
selected_option = select_obj.first_selected_option
@ -3367,13 +3385,18 @@ def tixcraft_ticket_main(driver, config_dict, ocr, Captcha_Browser, domain_name)
if row_text.isnumeric():
# ticket assign.
is_ticket_number_assigned = True
return is_ticket_number_assigned
def tixcraft_ticket_main(driver, config_dict, ocr, Captcha_Browser, domain_name):
# use extension instead of selenium.
#tixcraft_ticket_main_agree(driver, config_dict)
is_ticket_number_assigned = tixcraft_assign_ticket_number(driver, config_dict)
# must wait select object ready to assign ticket number.
if not is_ticket_number_assigned:
# only this case: "ticket number not changed by bot" to play sound!
# PS: I assume each time assign ticket number will succufully changed, so let sound play first.
play_sound_while_ordering(config_dict)
# should not enter this block, due to extension done.
ticket_number = str(config_dict["ticket_number"])
is_ticket_number_assigned = tixcraft_ticket_number_auto_fill(driver, select_obj, ticket_number)
@ -4679,7 +4702,6 @@ def kktix_reg_auto_reload(driver, url, config_dict, kktix_register_status_last):
is_need_refresh = True
is_finish_checkbox_click = False
if config_dict["auto_check_agree"]:
if not is_need_refresh:
is_need_refresh, is_finish_checkbox_click = kktix_check_agree_checkbox(driver, config_dict)
if not is_finish_checkbox_click:
@ -7536,7 +7558,6 @@ def ticketmaster_captcha(driver, config_dict, ocr, Captcha_Browser, domain_name)
away_from_keyboard_enable = False
ocr_captcha_image_source = config_dict["ocr_captcha"]["image_source"]
if config_dict["auto_check_agree"]:
for i in range(2):
is_finish_checkbox_click = tixcraft_ticket_agree(driver, config_dict)
if is_finish_checkbox_click:
@ -7644,6 +7665,13 @@ def tixcraft_main(driver, url, config_dict, tixcraft_dict, ocr, Captcha_Browser)
tixcraft_ticket_main(driver, config_dict, ocr, Captcha_Browser, domain_name)
tixcraft_dict["done_time"] = time.time()
if not tixcraft_dict["played_sound"]:
play_sound_while_ordering(config_dict)
tixcraft_dict["played_sound"] = True
else:
tixcraft_dict["played_sound"] = False
if '/ticket/order' in url:
tixcraft_dict["done_time"] = time.time()
@ -8791,8 +8819,6 @@ def ibon_main(driver, url, config_dict, ibon_dict, ocr, Captcha_Browser):
if is_event_page:
is_finish_checkbox_click = False
if is_event_page:
auto_check_agree = config_dict["auto_check_agree"]
if auto_check_agree:
for i in range(3):
is_finish_checkbox_click = ibon_ticket_agree(driver)
if is_finish_checkbox_click:
@ -12212,6 +12238,7 @@ def main(args):
tixcraft_dict["elapsed_time"]=None
tixcraft_dict["is_popup_checkout"] = False
tixcraft_dict["area_retry_count"]=0
tixcraft_dict["played_sound"] = False
# for kktix
kktix_dict = {}

View File

@ -22,7 +22,7 @@ import sys
import threading
import webbrowser
CONST_APP_VERSION = "MaxBot (2023.12.12)"
CONST_APP_VERSION = "MaxBot (2023.12.16)"
CONST_MAXBOT_LAUNCHER_FILE = "config_launcher.json"
CONST_MAXBOT_CONFIG_FILE = "settings.json"

View File

@ -1 +1 @@
{"homepage": "https://tixcraft.com", "browser": "chrome", "language": "\u7e41\u9ad4\u4e2d\u6587", "ticket_number": 2, "auto_check_agree": true, "ocr_captcha": {"enable": true, "beta": true, "force_submit": true, "image_source": "canvas"}, "webdriver_type": "undetected_chromedriver", "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true}, "tixcraft": {"date_auto_select": {"enable": true, "date_keyword": "", "mode": "from top to bottom"}, "pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true}, "area_auto_select": {"enable": true, "mode": "from top to bottom", "area_keyword": ""}, "keyword_exclude": "\"\u8f2a\u6905\",\"\u8eab\u969c\",\"\u8eab\u5fc3 \u969c\u7919\",\"Restricted View\",\"\u71c8\u67f1\u906e\u853d\",\"\u8996\u7dda\u4e0d\u5b8c\u6574\"", "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": "", "adblock_plus_enable": false, "disable_adjacent_seat": false, "hide_some_image": true, "block_facebook_network": true, "headless": false, "verbose": false, "auto_guess_options": true, "user_guess_string": "", "online_dictionary_url": "", "auto_reload_page_interval": 1.0, "auto_reload_random_delay": false, "proxy_server_port": ""}}
{"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", "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true}, "tixcraft": {"date_auto_select": {"enable": true, "date_keyword": "", "mode": "random"}, "pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true}, "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\"", "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": "", "adblock_plus_enable": false, "disable_adjacent_seat": false, "hide_some_image": true, "block_facebook_network": false, "headless": false, "verbose": true, "auto_guess_options": true, "user_guess_string": "", "online_dictionary_url": "", "auto_reload_page_interval": 1.0, "auto_reload_random_delay": false, "proxy_server_port": ""}}

View File

@ -34,7 +34,7 @@ import ssl
ssl._create_default_https_context = ssl._create_unverified_context
CONST_APP_VERSION = "MaxBot (2023.12.15)"
CONST_APP_VERSION = "MaxBot (2023.12.16)"
CONST_MAXBOT_CONFIG_FILE = "settings.json"
CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt"
@ -121,7 +121,6 @@ def load_translate():
en_us["language"] = 'Language'
en_us["ticket_number"] = 'Ticker Number'
en_us["auto_check_agree"] = 'Auto check agree checkbox'
en_us["enable"] = 'Enable'
en_us["recommand_enable"] = "Recommended to enable"
@ -229,8 +228,6 @@ def load_translate():
zh_tw["language"] = '語言'
zh_tw["ticket_number"] = '門票張數'
zh_tw["auto_check_agree"] = '自動勾選同意'
zh_tw["enable"] = '啟用'
zh_tw["recommand_enable"] = "建議啟用"
zh_tw["auto_press_next_step_button"] = '自動點選下一步按鈕'
@ -336,7 +333,6 @@ def load_translate():
zh_cn["language"] = '语言'
zh_cn["ticket_number"] = '门票张数'
zh_cn["auto_check_agree"] = '自动勾选同意'
zh_cn["enable"] = '启用'
zh_cn["recommand_enable"] = "建议启用"
@ -444,7 +440,6 @@ def load_translate():
ja_jp["language"] = '言語'
ja_jp["ticket_number"] = '枚数'
ja_jp["auto_check_agree"] = '自動的に同意をチェック'
ja_jp["enable"] = '有効'
ja_jp["recommand_enable"] = "有効化を推奨"
@ -627,7 +622,6 @@ def get_default_config():
config_dict["browser"] = "chrome"
config_dict["language"] = "English"
config_dict["ticket_number"] = 2
config_dict["auto_check_agree"] = True
config_dict["ocr_captcha"] = {}
config_dict["ocr_captcha"]["enable"] = True
config_dict["ocr_captcha"]["beta"] = True
@ -772,7 +766,6 @@ def btn_save_act(language_code, slience_mode=False):
global combo_browser
global combo_language
global combo_ticket_number
global chk_state_auto_check_agree
global chk_state_auto_press_next_step_button
global chk_state_auto_fill_ticket_number
@ -870,8 +863,6 @@ def btn_save_act(language_code, slience_mode=False):
config_dict["ticket_number"] = int(combo_ticket_number.get().strip())
if is_all_data_correct:
config_dict["auto_check_agree"] = bool(chk_state_auto_check_agree.get())
config_dict["kktix"]["auto_press_next_step_button"] = bool(chk_state_auto_press_next_step_button.get())
config_dict["kktix"]["auto_fill_ticket_number"] = bool(chk_state_auto_fill_ticket_number.get())
@ -1248,7 +1239,6 @@ def applyNewLanguage():
global lbl_browser
global lbl_language
global lbl_ticket_number
global lbl_auto_check_agree
# for kktix
global lbl_auto_press_next_step_button
@ -1282,8 +1272,6 @@ def applyNewLanguage():
global lbl_maxbot_last_url
# for checkbox
global chk_auto_check_agree
global chk_auto_press_next_step_button
global chk_auto_fill_ticket_number
global chk_date_auto_select
@ -1330,7 +1318,6 @@ def applyNewLanguage():
lbl_browser.config(text=translate[language_code]["browser"])
lbl_language.config(text=translate[language_code]["language"])
lbl_ticket_number.config(text=translate[language_code]["ticket_number"])
lbl_auto_check_agree.config(text=translate[language_code]["auto_check_agree"])
lbl_auto_press_next_step_button.config(text=translate[language_code]["auto_press_next_step_button"])
lbl_auto_fill_ticket_number.config(text=translate[language_code]["auto_fill_ticket_number"])
@ -1374,7 +1361,6 @@ def applyNewLanguage():
lbl_maxbot_status.config(text=translate[language_code]["running_status"])
lbl_maxbot_last_url.config(text=translate[language_code]["running_url"])
chk_auto_check_agree.config(text=translate[language_code]["enable"])
chk_auto_press_next_step_button.config(text=translate[language_code]["enable"])
chk_auto_fill_ticket_number.config(text=translate[language_code]["enable"])
chk_date_auto_select.config(text=translate[language_code]["enable"])
@ -1683,20 +1669,6 @@ def PreferenctTab(root, config_dict, language_code, UI_PADDING_X):
combo_ticket_number.set(str(config_dict["ticket_number"]))
combo_ticket_number.grid(column=1, row=group_row_count, sticky = W)
group_row_count+=1
global lbl_auto_check_agree
lbl_auto_check_agree = Label(frame_group_header, text=translate[language_code]['auto_check_agree'])
lbl_auto_check_agree.grid(column=0, row=group_row_count, sticky = E)
global chk_state_auto_check_agree
chk_state_auto_check_agree = BooleanVar()
chk_state_auto_check_agree.set(config_dict["auto_check_agree"])
global chk_auto_check_agree
chk_auto_check_agree = Checkbutton(frame_group_header, text=translate[language_code]['enable'], variable=chk_state_auto_check_agree)
chk_auto_check_agree.grid(column=1, row=group_row_count, sticky = W)
frame_group_header.grid(column=0, row=row_count, sticky = W, padx=UI_PADDING_X)
row_count+=1

View File

@ -27,7 +27,7 @@ import pyperclip
import tornado
from tornado.web import Application
CONST_APP_VERSION = "MaxBot (2023.12.12)"
CONST_APP_VERSION = "MaxBot (2023.12.16)"
CONST_MAXBOT_QUESTION_FILE = "MAXBOT_QUESTION.txt"

View File

View File

@ -0,0 +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", "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true}, "tixcraft": {"date_auto_select": {"enable": true, "date_keyword": "", "mode": "random"}, "pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true}, "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\"", "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": "", "adblock_plus_enable": false, "disable_adjacent_seat": false, "hide_some_image": false, "block_facebook_network": false, "headless": false, "verbose": true, "auto_guess_options": true, "user_guess_string": "", "online_dictionary_url": "", "auto_reload_page_interval": 1.0, "auto_reload_random_delay": false, "proxy_server_port": ""}}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 555 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

2
webdriver/Maxbot_1.0.0/jquery.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,3 @@
$('input[type=checkbox]').each(function() {
$(this).prop('checked', true);
});

View File

@ -0,0 +1,9 @@
$("footer").hide();
function hideBannerAndImage() {
$("div.banner-wrapper").hide();
$("div.ticket-img-wrapper").hide();
$('input[type=checkbox]').each(function() {
$(this).prop('checked', true);
});
}
setTimeout(hideBannerAndImage, 300);

View File

@ -0,0 +1,3 @@
$("ul.area-list > li:not(:has(a))").hide();
$("#selectseat div div img").hide();
$("footer").hide();

View File

@ -0,0 +1 @@
$("footer").hide();

View File

@ -0,0 +1,2 @@
$("#newsHome").hide();
$("footer").hide();

View File

@ -0,0 +1,48 @@
$('input[type=checkbox]').each(function ()
{
$(this).prop('checked', true);
}
);
$("img[style='width: 100%; padding: 0;']").hide();
$("footer").hide();
function assign_ticket_number(ticket_number)
{
if ($("#ticketPriceList select").length > 0)
{
let $ticket_options = $("#ticketPriceList select:first option");
if ($ticket_options.length)
{
let is_ticket_number_assign = false;
if (ticket_number > 0)
{
$ticket_options.each(function ()
{
if ($(this).val() == ticket_number)
{
$(this).prop('selected', true);
is_ticket_number_assign = true;
return false;
}
}
);
}
if (!is_ticket_number_assign)
{
$ticket_options.last().prop('selected', true);
}
}
}
}
function initSettings()
{
fetch(chrome.extension.getURL("/data/settings.json"))
.then((resp) => resp.json())
.then((settings) =>
{
assign_ticket_number(settings.ticket_number);
}
);
}
initSettings();

View File

@ -0,0 +1,67 @@
{
"author": "Max Yao",
"name": "MaxBot",
"icons": {
"16": "icons/maxbot-16.png",
"32": "icons/maxbot-32.png",
"48": "icons/maxbot-48.png",
"64": "icons/maxbot-64.png",
"128": "icons/maxbot-128.png"
},
"manifest_version": 2,
"background": {
"persistent": true,
"scripts": [
"background.js"
]
},
"minimum_chrome_version": "77.0",
"minimum_opera_version": "64.0",
"permissions": [
"<all_urls>",
"contextMenus",
"notifications",
"storage",
"tabs",
"unlimitedStorage",
"webNavigation",
"webRequest",
"webRequestBlocking"
],
"host_permissions": [
"*://*/*"
],
"web_accessible_resources": [
"data/settings.json"
],
"content_scripts" : [
{
"matches" : [ "https://tixcraft.com/ticket/area/*" ],
"run_at": "document_end",
"js" : [ "jquery.min.js", "js/tixcraft_area.js" ]
},
{
"matches" : [ "https://tixcraft.com/activity/game/*" ],
"run_at": "document_end",
"js" : [ "jquery.min.js", "js/tixcraft_game.js" ]
},
{
"matches" : [ "https://tixcraft.com/ticket/ticket/*" ],
"run_at": "document_end",
"js" : [ "jquery.min.js", "js/tixcraft_ticket.js" ]
},
{
"matches" : [ "https://tixcraft.com/" ],
"run_at": "document_end",
"js" : [ "jquery.min.js", "js/tixcraft_home.js" ]
},
{
"matches" : [
"https://kktix.com/events/*/registrations/new"
],
"run_at": "document_end",
"js" : [ "jquery.min.js", "js/kktix_registrations_new.js" ]
}
],
"version": "1.0.0"
}