From 949d192b36e3a68ec51b1f57027830bfce904074 Mon Sep 17 00:00:00 2001 From: CHUN YU YAO Date: Sun, 7 Apr 2024 13:13:31 +0800 Subject: [PATCH] 2024-03-25, update for kktix racing with web drver --- chrome_tixcraft.py | 2 +- config_launcher.py | 2 +- kktix_status.py | 2 +- nodriver_tixcraft.py | 2 +- settings.py | 2 +- webdriver/Maxbotplus_1.0.0/js/common.js | 24 +++++++++++++++---- .../js/kktix_registrations_assign.js | 18 ++++++++++---- 7 files changed, 38 insertions(+), 14 deletions(-) diff --git a/chrome_tixcraft.py b/chrome_tixcraft.py index 3b230cb..4f41186 100644 --- a/chrome_tixcraft.py +++ b/chrome_tixcraft.py @@ -44,7 +44,7 @@ except Exception as exc: print(exc) pass -CONST_APP_VERSION = "MaxBot (2024.03.24)" +CONST_APP_VERSION = "MaxBot (2024.03.25)" CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt" CONST_MAXBOT_CONFIG_FILE = "settings.json" diff --git a/config_launcher.py b/config_launcher.py index e3f7c3b..7eb6059 100644 --- a/config_launcher.py +++ b/config_launcher.py @@ -24,7 +24,7 @@ import webbrowser import util -CONST_APP_VERSION = "MaxBot (2024.03.24)" +CONST_APP_VERSION = "MaxBot (2024.03.25)" CONST_MAXBOT_LAUNCHER_FILE = "config_launcher.json" CONST_MAXBOT_CONFIG_FILE = "settings.json" diff --git a/kktix_status.py b/kktix_status.py index 2f942a0..8944a5f 100644 --- a/kktix_status.py +++ b/kktix_status.py @@ -29,7 +29,7 @@ from datetime import datetime import util -CONST_APP_VERSION = "MaxBot (2024.03.24)" +CONST_APP_VERSION = "MaxBot (2024.03.25)" CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_KKTIX_CONFIG_FILE = "kktix.json" diff --git a/nodriver_tixcraft.py b/nodriver_tixcraft.py index 1d06e5e..bc5abcb 100644 --- a/nodriver_tixcraft.py +++ b/nodriver_tixcraft.py @@ -32,7 +32,7 @@ except Exception as exc: print(exc) pass -CONST_APP_VERSION = "MaxBot (2024.03.24)" +CONST_APP_VERSION = "MaxBot (2024.03.25)" CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt" CONST_MAXBOT_CONFIG_FILE = "settings.json" diff --git a/settings.py b/settings.py index 9933db7..5ed329c 100644 --- a/settings.py +++ b/settings.py @@ -41,7 +41,7 @@ try: except Exception as exc: pass -CONST_APP_VERSION = "MaxBot (2024.03.24)" +CONST_APP_VERSION = "MaxBot (2024.03.25)" CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt" CONST_MAXBOT_CONFIG_FILE = "settings.json" diff --git a/webdriver/Maxbotplus_1.0.0/js/common.js b/webdriver/Maxbotplus_1.0.0/js/common.js index cfed655..ac584c9 100644 --- a/webdriver/Maxbotplus_1.0.0/js/common.js +++ b/webdriver/Maxbotplus_1.0.0/js/common.js @@ -5,7 +5,12 @@ function get_target_area_with_order(settings, matched_block) if(matched_block.length) { let last_index = matched_block.length-1 - let center_index = parseInt(last_index/2); + let center_index = 0; + let random_index = 0; + if(matched_block.length>1) { + center_index = parseInt(last_index/2); + random_index = getRandom(0,last_index) + } if(settings.area_auto_select.mode=="from top to bottom") target_area = matched_block[0]; if(settings.area_auto_select.mode=="from bottom to top") @@ -13,7 +18,7 @@ function get_target_area_with_order(settings, matched_block) if(settings.area_auto_select.mode=="center") target_area = matched_block[center_index]; if(settings.area_auto_select.mode=="random") - target_area = matched_block[0]; + target_area = matched_block[random_index]; } return target_area; } @@ -25,7 +30,12 @@ function get_target_date_with_order(settings, matched_block) if(matched_block.length) { let last_index = matched_block.length-1 - let center_index = parseInt(last_index/2); + let center_index = 0; + let random_index = 0; + if(matched_block.length>1) { + center_index = parseInt(last_index/2); + random_index = getRandom(0,last_index) + } if(settings.date_auto_select.mode=="from top to bottom") target_area = matched_block[0]; if(settings.date_auto_select.mode=="from bottom to top") @@ -33,8 +43,12 @@ function get_target_date_with_order(settings, matched_block) if(settings.date_auto_select.mode=="center") target_area = matched_block[center_index]; if(settings.date_auto_select.mode=="random") - target_area = matched_block[0]; + target_area = matched_block[random_index]; } return target_area; -} \ No newline at end of file +} + +function getRandom(min,max){ + return Math.floor(Math.random()*(max-min+1))+min; +}; \ No newline at end of file diff --git a/webdriver/Maxbotplus_1.0.0/js/kktix_registrations_assign.js b/webdriver/Maxbotplus_1.0.0/js/kktix_registrations_assign.js index e79458d..49d89a0 100644 --- a/webdriver/Maxbotplus_1.0.0/js/kktix_registrations_assign.js +++ b/webdriver/Maxbotplus_1.0.0/js/kktix_registrations_assign.js @@ -46,9 +46,9 @@ function kktix_area_keyword(settings, base_info, register_info) } // console.log(area_keyword_array); let target_area = null; + let matched_block=[]; if(area_keyword_array.length) { for (let i = 0; i < area_keyword_array.length; i++) { - let matched_block=[]; $("div.ticket-unit").each(function () { let html_text=$(this).text(); @@ -64,7 +64,6 @@ function kktix_area_keyword(settings, base_info, register_info) } } } else { - let matched_block=[]; $("div.ticket-unit").each(function () { matched_block.push($(this)); @@ -147,6 +146,7 @@ function kktix_area_keyword(settings, base_info, register_info) } } + let hide_other_row = false; if(auto_click_next_btn) { let $next_btn = $('div.register-new-next-button-area > button'); if($next_btn) { @@ -155,6 +155,17 @@ function kktix_area_keyword(settings, base_info, register_info) } else { $next_btn.click(); } + hide_other_row = true; + } + } + + // due to racing with web driver. + if(hide_other_row) { + for (let i = 0; i < matched_block.length; i++) { + if(target_area!=matched_block[i]) + { + matched_block[i].remove(); + } } } } @@ -196,9 +207,8 @@ if(rootElement) { if(!dom_ready()) { myInterval = setInterval(() => { dom_ready(); - }, 400); + }, 200); } - $("footer").remove(); $("div.banner-wrapper div.img-wrapper img").remove(); }