2023-12-26, fix fot kktix.

master
CHUN YU YAO 2024-01-05 23:57:40 +08:00
parent d5e942da74
commit 013a4d01f3
7 changed files with 102 additions and 63 deletions

View File

@ -54,7 +54,7 @@ import webbrowser
import chromedriver_autoinstaller import chromedriver_autoinstaller
CONST_APP_VERSION = "MaxBot (2023.12.25)" CONST_APP_VERSION = "MaxBot (2023.12.26)"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"
CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt" CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt"
@ -3595,19 +3595,19 @@ def kktix_travel_price_list(driver, config_dict, kktix_area_auto_select_mode, kk
ticket_price_list = driver.find_elements(By.CSS_SELECTOR, 'div.display-table-row') ticket_price_list = driver.find_elements(By.CSS_SELECTOR, 'div.display-table-row')
except Exception as exc: except Exception as exc:
ticket_price_list = None ticket_price_list = None
print("find ticket-price span Exception:") print("find ticket-price Exception:")
print(exc) print(exc)
pass pass
is_dom_ready = True
price_list_count = 0 price_list_count = 0
if not ticket_price_list is None: if not ticket_price_list is None:
price_list_count = len(ticket_price_list) price_list_count = len(ticket_price_list)
if show_debug_message: if show_debug_message:
print("found price count:", price_list_count) print("found price count:", price_list_count)
else: else:
print("find ticket-price span fail") is_dom_ready = False
print("find ticket-price fail")
is_travel_interrupted = False
if price_list_count > 0: if price_list_count > 0:
areas = [] areas = []
@ -3634,7 +3634,7 @@ def kktix_travel_price_list(driver, config_dict, kktix_area_auto_select_mode, kk
row_html = row.get_attribute('innerHTML') row_html = row.get_attribute('innerHTML')
row_text = remove_html_tags(row_html) row_text = remove_html_tags(row_html)
except Exception as exc: except Exception as exc:
is_travel_interrupted = True is_dom_ready = False
if show_debug_message: if show_debug_message:
print(exc) print(exc)
# error, exit loop # error, exit loop
@ -3778,7 +3778,7 @@ def kktix_travel_price_list(driver, config_dict, kktix_area_auto_select_mode, kk
break break
if is_travel_interrupted: if not is_dom_ready:
# not sure to break or continue..., maybe break better. # not sure to break or continue..., maybe break better.
break break
else: else:
@ -3786,11 +3786,7 @@ def kktix_travel_price_list(driver, config_dict, kktix_area_auto_select_mode, kk
print("no any price list found.") print("no any price list found.")
pass pass
# unknow issue... return is_dom_ready, is_ticket_number_assigned, areas
if is_travel_interrupted:
pass
return is_ticket_number_assigned, areas
def kktix_assign_ticket_number(driver, config_dict, kktix_area_keyword): def kktix_assign_ticket_number(driver, config_dict, kktix_area_keyword):
show_debug_message = True # debug. show_debug_message = True # debug.
@ -3804,13 +3800,15 @@ def kktix_assign_ticket_number(driver, config_dict, kktix_area_keyword):
is_ticket_number_assigned = False is_ticket_number_assigned = False
matched_blocks = None matched_blocks = None
is_ticket_number_assigned, matched_blocks = kktix_travel_price_list(driver, config_dict, auto_select_mode, kktix_area_keyword) is_dom_ready = True
is_dom_ready, is_ticket_number_assigned, matched_blocks = kktix_travel_price_list(driver, config_dict, auto_select_mode, kktix_area_keyword)
target_area = None target_area = None
is_need_refresh = False
if is_dom_ready:
if not is_ticket_number_assigned: if not is_ticket_number_assigned:
target_area = get_target_item_from_matched_list(matched_blocks, auto_select_mode) target_area = get_target_item_from_matched_list(matched_blocks, auto_select_mode)
is_need_refresh = False
if not matched_blocks is None: if not matched_blocks is None:
if len(matched_blocks) == 0: if len(matched_blocks) == 0:
is_need_refresh = True is_need_refresh = True
@ -3849,7 +3847,7 @@ def kktix_assign_ticket_number(driver, config_dict, kktix_area_keyword):
# already assigned. # already assigned.
is_ticket_number_assigned = True is_ticket_number_assigned = True
return is_ticket_number_assigned, is_need_refresh return is_dom_ready, is_ticket_number_assigned, is_need_refresh
def kktix_get_web_datetime(registrationsNewApp_div): def kktix_get_web_datetime(registrationsNewApp_div):
show_debug_message = True # debug. show_debug_message = True # debug.
@ -4548,6 +4546,7 @@ def kktix_reg_new_main(driver, config_dict, fail_list, captcha_sound_played, is_
# part 2: assign ticket number # part 2: assign ticket number
is_ticket_number_assigned = False is_ticket_number_assigned = False
if not registrationsNewApp_div is None: if not registrationsNewApp_div is None:
is_dom_ready = True
is_need_refresh = False is_need_refresh = False
if len(area_keyword) > 0: if len(area_keyword) > 0:
@ -4561,7 +4560,11 @@ def kktix_reg_new_main(driver, config_dict, fail_list, captcha_sound_played, is_
is_need_refresh_final = True is_need_refresh_final = True
for area_keyword_item in area_keyword_array: for area_keyword_item in area_keyword_array:
is_ticket_number_assigned, is_need_refresh_tmp = kktix_assign_ticket_number(driver, config_dict, area_keyword_item) is_dom_ready, is_ticket_number_assigned, is_need_refresh_tmp = kktix_assign_ticket_number(driver, config_dict, area_keyword_item)
if not is_dom_ready:
# page redirecting.
break
# one of keywords not need to refresh, final is not refresh. # one of keywords not need to refresh, final is not refresh.
if not is_need_refresh_tmp: if not is_need_refresh_tmp:
@ -4577,8 +4580,9 @@ def kktix_reg_new_main(driver, config_dict, fail_list, captcha_sound_played, is_
is_need_refresh = is_need_refresh_final is_need_refresh = is_need_refresh_final
else: else:
# empty keyword, match all. # empty keyword, match all.
is_ticket_number_assigned, is_need_refresh = kktix_assign_ticket_number(driver, config_dict, "") is_dom_ready, is_ticket_number_assigned, is_need_refresh = kktix_assign_ticket_number(driver, config_dict, "")
if is_dom_ready:
# part 3: captcha # part 3: captcha
if is_ticket_number_assigned: if is_ticket_number_assigned:
fail_list, captcha_sound_played, is_question_popup = kktix_reg_captcha(driver, config_dict, fail_list, captcha_sound_played, is_finish_checkbox_click, registrationsNewApp_div) fail_list, captcha_sound_played, is_question_popup = kktix_reg_captcha(driver, config_dict, fail_list, captcha_sound_played, is_finish_checkbox_click, registrationsNewApp_div)

View File

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

View File

@ -34,7 +34,7 @@ import ssl
ssl._create_default_https_context = ssl._create_unverified_context ssl._create_default_https_context = ssl._create_unverified_context
CONST_APP_VERSION = "MaxBot (2023.12.25)" CONST_APP_VERSION = "MaxBot (2023.12.26)"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"
CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt" CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt"

View File

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

View File

@ -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", "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": 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://kktix.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": "weng.32002@gmail.com", "fami_account": "", "cityline_account": "", "urbtix_account": "", "hkticketing_account": "", "kham_account": "", "ticket_account": "", "udn_account": "", "ticketplus_account": "", "facebook_password": "", "kktix_password": "eXlme2omX3Nq", "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

@ -1,12 +1,55 @@
const storage = chrome.storage.local; const storage = chrome.storage.local;
$("footer").remove(); var myInterval = null;
setTimeout(function () { function clean_sold_out_row(data)
{
console.log("clean_sold_out_row");
let match_target = false;
for (var key in data.inventory.ticketInventory) {
if(data.inventory.ticketInventory[key]) {
//console.log("key:"+key);
if($("#ticket_"+key).length) {
match_target = true;
break;
}
}
}
//console.log("match_target:"+match_target);
if(match_target) {
$("footer").remove();
$("div.banner-wrapper").remove(); $("div.banner-wrapper").remove();
$("div.ticket-img-wrapper").remove(); $("div.ticket-img-wrapper").remove();
}, 300);
$("span.ticket-quantity[ng-if=\"!purchasableAndSelectable\"]").each(function ()
{
$(this).parent().parent().parent().remove();
});
clearInterval(myInterval);
}
}
function kktix_ajax_done(data)
{
let reload=false;
console.log(data.inventory.registerStatus);
// IN_STOCK
if(data.inventory.registerStatus=='OUT_OF_STOCK') {reload=true;}
if(data.inventory.registerStatus=='COMING_SOON') {reload=true;}
if(data.inventory.registerStatus=='SOLD_OUT') {reload=true;}
//console.log(reload);
if(reload) {
location.reload();
} else {
$(function() {
myInterval = setInterval(() => {
clean_sold_out_row(data);
}, 200);
});
}
}
function kktix_event_status_check() function kktix_event_status_check()
{ {
@ -21,14 +64,7 @@ function kktix_event_status_check()
}) })
.done(function(data) { .done(function(data) {
//alert( "second success" ); //alert( "second success" );
let reload=false; kktix_ajax_done(data);
console.log(data.inventory.registerStatus);
// IN_STOCK
if(data.inventory.registerStatus=='OUT_OF_STOCK') {reload=true;}
if(data.inventory.registerStatus=='COMING_SOON') {reload=true;}
if(data.inventory.registerStatus=='SOLD_OUT') {reload=true;}
//console.log(reload);
if(reload) {location.reload();}
}) })
.fail(function() { .fail(function() {
//alert( "error" ); //alert( "error" );

View File

@ -20,8 +20,7 @@ function date_clean()
$("#gameList td:contains('"+ remove_list[i] +"')").each(function () $("#gameList td:contains('"+ remove_list[i] +"')").each(function ()
{ {
$(this).parent().remove(); $(this).parent().remove();
} });
);
} }
} }