2024-04-20, update for kktix bus question

master
Your Name 2024-07-03 22:32:34 +08:00
parent ccbc811dbd
commit 6ab0fd75d7
18 changed files with 225 additions and 39 deletions

View File

@ -44,7 +44,7 @@ except Exception as exc:
print(exc) print(exc)
pass pass
CONST_APP_VERSION = "MaxBot (2024.04.19)" CONST_APP_VERSION = "MaxBot (2024.04.20)"
CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt" CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"
@ -11042,6 +11042,7 @@ def cli():
def test_captcha_model(): def test_captcha_model():
#for test kktix answer. #for test kktix answer.
captcha_text_div_text = "請輸入括弧內數字( 2741 )" captcha_text_div_text = "請輸入括弧內數字( 2741 )"
captcha_text_div_text = "請將括弧內文字轉換為阿拉伯數字(一二三四五六)"
answer_list = util.get_answer_list_from_question_string(None, captcha_text_div_text) answer_list = util.get_answer_list_from_question_string(None, captcha_text_div_text)
print("answer_list:", answer_list) print("answer_list:", answer_list)

View File

@ -24,7 +24,7 @@ import webbrowser
import util import util
CONST_APP_VERSION = "MaxBot (2024.04.19)" CONST_APP_VERSION = "MaxBot (2024.04.20)"
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

@ -32,7 +32,7 @@ except Exception as exc:
print(exc) print(exc)
pass pass
CONST_APP_VERSION = "MaxBot (2024.04.19)" CONST_APP_VERSION = "MaxBot (2024.04.20)"
CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt" CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"

View File

@ -81,6 +81,8 @@
"user_guess_string": "", "user_guess_string": "",
"remote_url": "\"http://127.0.0.1:16888/\"", "remote_url": "\"http://127.0.0.1:16888/\"",
"auto_reload_page_interval": 0.1, "auto_reload_page_interval": 0.1,
"auto_reload_overheat_count": 4,
"auto_reload_overheat_cd": 1,
"reset_browser_interval": 0, "reset_browser_interval": 0,
"proxy_server_port": "", "proxy_server_port": "",
"window_size": "480,1024", "window_size": "480,1024",

View File

@ -39,7 +39,7 @@ try:
except Exception as exc: except Exception as exc:
pass pass
CONST_APP_VERSION = "MaxBot (2024.04.19)" CONST_APP_VERSION = "MaxBot (2024.04.20)"
CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt" CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"
@ -190,6 +190,8 @@ def get_default_config():
config_dict["advanced"]["remote_url"] = "\"http://127.0.0.1:%d/\"" % (CONST_SERVER_PORT) config_dict["advanced"]["remote_url"] = "\"http://127.0.0.1:%d/\"" % (CONST_SERVER_PORT)
config_dict["advanced"]["auto_reload_page_interval"] = 0.1 config_dict["advanced"]["auto_reload_page_interval"] = 0.1
config_dict["advanced"]["auto_reload_overheat_count"] = 4
config_dict["advanced"]["auto_reload_overheat_cd"] = 1.0
config_dict["advanced"]["reset_browser_interval"] = 0 config_dict["advanced"]["reset_browser_interval"] = 0
config_dict["advanced"]["proxy_server_port"] = "" config_dict["advanced"]["proxy_server_port"] = ""
config_dict["advanced"]["window_size"] = "480,1024" config_dict["advanced"]["window_size"] = "480,1024"

View File

@ -34,7 +34,7 @@ try:
except Exception as exc: except Exception as exc:
pass pass
CONST_APP_VERSION = "MaxBot (2024.04.19)" CONST_APP_VERSION = "MaxBot (2024.04.20)"
CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt" CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt"
CONST_MAXBOT_CONFIG_FILE = "settings.json" CONST_MAXBOT_CONFIG_FILE = "settings.json"
@ -675,6 +675,8 @@ def get_default_config():
config_dict["advanced"]["remote_url"] = "http://127.0.0.1:%d/" % (CONST_SERVER_PORT) config_dict["advanced"]["remote_url"] = "http://127.0.0.1:%d/" % (CONST_SERVER_PORT)
config_dict["advanced"]["auto_reload_page_interval"] = 0.1 config_dict["advanced"]["auto_reload_page_interval"] = 0.1
config_dict["advanced"]["auto_reload_overheat_count"] = 4
config_dict["advanced"]["auto_reload_overheat_cd"] = 1.0
config_dict["advanced"]["reset_browser_interval"] = 0 config_dict["advanced"]["reset_browser_interval"] = 0
config_dict["advanced"]["proxy_server_port"] = "" config_dict["advanced"]["proxy_server_port"] = ""
config_dict["advanced"]["window_size"] = "480,1024" config_dict["advanced"]["window_size"] = "480,1024"

45
util.py
View File

@ -1814,6 +1814,51 @@ def get_answer_list_from_question_string(registrationsNewApp_div, captcha_text_d
inferred_answer_string = temp_answer inferred_answer_string = temp_answer
# 請將括弧內文字轉換為阿拉伯數字
if inferred_answer_string is None:
formated_html_text = captcha_text_div_text.strip()
formated_html_text = format_quota_string(formated_html_text)
formated_html_text = formated_html_text.replace('請輸入','輸入')
formated_html_text = formated_html_text.replace('','')
formated_html_text = formated_html_text.replace('之內','')
formated_html_text = formated_html_text.replace('之中','')
formated_html_text = formated_html_text.replace('括弧','括號')
formated_html_text = formated_html_text.replace('引號','括號')
formated_html_text = formated_html_text.replace('括號中','括號內')
formated_html_text = formated_html_text.replace('修改','轉換')
formated_html_text = formated_html_text.replace('調整','轉換')
formated_html_text = formated_html_text.replace('改變','轉換')
formated_html_text = formated_html_text.replace('改為','轉換')
formated_html_text = formated_html_text.replace('置換','轉換')
formated_html_text = formated_html_text.replace('換成','轉換')
is_match_input_quota_text = False
if len(formated_html_text) <= 30:
print("formated_html_text:", formated_html_text)
if not '\n' in formated_html_text:
if '' in formated_html_text and '' in formated_html_text:
is_match_input_quota_text = True
# check target text terms.
if is_match_input_quota_text:
target_text_list = ["轉換","數字","文字"]
for item in target_text_list:
if not item in formated_html_text:
is_match_input_quota_text = False
break
if is_match_input_quota_text:
temp_answer = find_between(formated_html_text, "", "")
temp_answer = temp_answer.strip()
if len(temp_answer) > 0:
temp_answer = temp_answer.replace(' ','')
temp_answer = normalize_chinese_numeric(temp_answer)
inferred_answer_string = temp_answer
if inferred_answer_string is None: if inferred_answer_string is None:
is_use_quota_message = False is_use_quota_message = False
if "" in captcha_text_div_text and "" in captcha_text_div_text: if "" in captcha_text_div_text and "" in captcha_text_div_text:

View File

@ -1 +1 @@
{"homepage": "about:blank", "browser": "chrome", "language": "English", "ticket_number": 2, "ocr_captcha": {"enable": true, "beta": true, "force_submit": true, "image_source": "canvas"}, "webdriver_type": "undetected_chromedriver", "date_auto_select": {"enable": true, "date_keyword": "", "mode": "random"}, "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\"", "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true, "max_dwell_time": 60}, "cityline": {"cityline_queue_retry": true}, "tixcraft": {"pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true}, "advanced": {"play_sound": {"ticket": true, "order": 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": "", "facebook_password_plaintext": "", "kktix_password_plaintext": "", "fami_password_plaintext": "", "urbtix_password_plaintext": "", "cityline_password_plaintext": "", "hkticketing_password_plaintext": "", "kham_password_plaintext": "", "ticket_password_plaintext": "", "udn_password_plaintext": "", "ticketplus_password_plaintext": "", "chrome_extension": true, "disable_adjacent_seat": false, "hide_some_image": false, "block_facebook_network": false, "headless": false, "verbose": false, "auto_guess_options": true, "user_guess_string": "", "remote_url": "\"http://127.0.0.1:16888/\"", "auto_reload_page_interval": 0.1, "reset_browser_interval": 0, "proxy_server_port": "", "window_size": "480,1024,1", "idle_keyword": "", "resume_keyword": "", "idle_keyword_second": "", "resume_keyword_second": ""}, "domain_filter": ["*.doubleclick.net/*", "*.googlesyndication.com/*", "*.ssp.hinet.net/*", "*a.amnet.tw/*", "*adx.c.appier.net/*", "*cdn.cookielaw.org/*", "*cdnjs.cloudflare.com/ajax/libs/clipboard.js/*", "*clarity.ms/*", "*cloudfront.com/*", "*cms.analytics.yahoo.com/*", "*e2elog.fetnet.net/*", "*fundingchoicesmessages.google.com/*", "*ghtinc.com/*", "*google-analytics.com/*", "*googletagmanager.com/*", "*googletagservices.com/*", "*img.uniicreative.com/*", "*lndata.com/*", "*match.adsrvr.org/*", "*onead.onevision.com.tw/*", "*play.google.com/log?*", "*popin.cc/*", "*rollbar.com/*", "*sb.scorecardresearch.com/*", "*tagtoo.co/*", "*ticketmaster.sg/js/adblock*", "*ticketmaster.sg/js/adblock.js*", "*tixcraft.com/js/analytics.js*", "*tixcraft.com/js/common.js*", "*tixcraft.com/js/custom.js*", "*treasuredata.com/*", "*www.youtube.com/youtubei/v1/player/heartbeat*"]} {"homepage": "about:blank", "browser": "chrome", "language": "English", "ticket_number": 2, "ocr_captcha": {"enable": true, "beta": true, "force_submit": true, "image_source": "canvas"}, "webdriver_type": "undetected_chromedriver", "date_auto_select": {"enable": true, "date_keyword": "", "mode": "random"}, "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\"", "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true, "max_dwell_time": 60}, "cityline": {"cityline_queue_retry": true}, "tixcraft": {"pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true}, "advanced": {"play_sound": {"ticket": true, "order": 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": "", "facebook_password_plaintext": "", "kktix_password_plaintext": "", "fami_password_plaintext": "", "urbtix_password_plaintext": "", "cityline_password_plaintext": "", "hkticketing_password_plaintext": "", "kham_password_plaintext": "", "ticket_password_plaintext": "", "udn_password_plaintext": "", "ticketplus_password_plaintext": "", "chrome_extension": true, "disable_adjacent_seat": false, "hide_some_image": false, "block_facebook_network": false, "headless": false, "verbose": false, "auto_guess_options": true, "user_guess_string": "", "remote_url": "\"http://127.0.0.1:16888/\"", "auto_reload_page_interval": 0.1, "auto_reload_overheat_count": 4, "auto_reload_overheat_cd": 1, "reset_browser_interval": 0, "proxy_server_port": "", "window_size": "480,1024,0", "idle_keyword": "", "resume_keyword": "", "idle_keyword_second": "", "resume_keyword_second": ""}, "domain_filter": ["*.doubleclick.net/*", "*.googlesyndication.com/*", "*.ssp.hinet.net/*", "*a.amnet.tw/*", "*adx.c.appier.net/*", "*cdn.cookielaw.org/*", "*cdnjs.cloudflare.com/ajax/libs/clipboard.js/*", "*clarity.ms/*", "*cloudfront.com/*", "*cms.analytics.yahoo.com/*", "*e2elog.fetnet.net/*", "*fundingchoicesmessages.google.com/*", "*ghtinc.com/*", "*google-analytics.com/*", "*googletagmanager.com/*", "*googletagservices.com/*", "*img.uniicreative.com/*", "*lndata.com/*", "*match.adsrvr.org/*", "*onead.onevision.com.tw/*", "*play.google.com/log?*", "*popin.cc/*", "*rollbar.com/*", "*sb.scorecardresearch.com/*", "*tagtoo.co/*", "*ticketmaster.sg/js/adblock*", "*ticketmaster.sg/js/adblock.js*", "*tixcraft.com/js/analytics.js*", "*tixcraft.com/js/common.js*", "*tixcraft.com/js/custom.js*", "*treasuredata.com/*", "*www.youtube.com/youtubei/v1/player/heartbeat*"]}

View File

@ -153,11 +153,19 @@ async function ocr(data_url, image_data, tabId)
); );
} }
// for avoid overheat.
chrome.storage.local.set(
{
last_reload_timestamp: []
}
);
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
let request_json = request; let request_json = request;
let result_json={"answer": "pong from background"}; let result_json={"answer": "pong from background"};
if(request_json.action=="decrypt") { if(request_json.action=="decrypt") {
console.log(typeof crypto_decrypt); //console.log(typeof crypto_decrypt);
let answer=""; let answer="";
if(typeof crypto_decrypt === 'function') { if(typeof crypto_decrypt === 'function') {
answer=crypto_decrypt(request_json.data.text,request_json.data.key,request_json.data.iv); answer=crypto_decrypt(request_json.data.text,request_json.data.key,request_json.data.iv);

View File

@ -1 +1 @@
{"homepage": "about:blank", "browser": "chrome", "language": "English", "ticket_number": 2, "ocr_captcha": {"enable": true, "beta": true, "force_submit": true, "image_source": "canvas"}, "webdriver_type": "undetected_chromedriver", "date_auto_select": {"enable": true, "date_keyword": "", "mode": "random"}, "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\"", "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true, "max_dwell_time": 60}, "cityline": {"cityline_queue_retry": true}, "tixcraft": {"pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true}, "advanced": {"play_sound": {"ticket": true, "order": 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": "", "facebook_password_plaintext": "", "kktix_password_plaintext": "", "fami_password_plaintext": "", "urbtix_password_plaintext": "", "cityline_password_plaintext": "", "hkticketing_password_plaintext": "", "kham_password_plaintext": "", "ticket_password_plaintext": "", "udn_password_plaintext": "", "ticketplus_password_plaintext": "", "chrome_extension": true, "disable_adjacent_seat": false, "hide_some_image": false, "block_facebook_network": false, "headless": false, "verbose": false, "auto_guess_options": true, "user_guess_string": "", "remote_url": "\"http://127.0.0.1:16888/\"", "auto_reload_page_interval": 0.1, "reset_browser_interval": 0, "proxy_server_port": "", "window_size": "480,1024,1", "idle_keyword": "", "resume_keyword": "", "idle_keyword_second": "", "resume_keyword_second": ""}} {"homepage": "about:blank", "browser": "chrome", "language": "English", "ticket_number": 2, "ocr_captcha": {"enable": true, "beta": true, "force_submit": true, "image_source": "canvas"}, "webdriver_type": "undetected_chromedriver", "date_auto_select": {"enable": true, "date_keyword": "", "mode": "random"}, "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\"", "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true, "max_dwell_time": 60}, "cityline": {"cityline_queue_retry": true}, "tixcraft": {"pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true}, "advanced": {"play_sound": {"ticket": true, "order": 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": "", "facebook_password_plaintext": "", "kktix_password_plaintext": "", "fami_password_plaintext": "", "urbtix_password_plaintext": "", "cityline_password_plaintext": "", "hkticketing_password_plaintext": "", "kham_password_plaintext": "", "ticket_password_plaintext": "", "udn_password_plaintext": "", "ticketplus_password_plaintext": "", "chrome_extension": true, "disable_adjacent_seat": false, "hide_some_image": false, "block_facebook_network": false, "headless": false, "verbose": false, "auto_guess_options": true, "user_guess_string": "", "remote_url": "\"http://127.0.0.1:16888/\"", "auto_reload_page_interval": 0.1, "auto_reload_overheat_count": 4, "auto_reload_overheat_cd": 1, "reset_browser_interval": 0, "proxy_server_port": "", "window_size": "480,1024,0", "idle_keyword": "", "resume_keyword": "", "idle_keyword_second": "", "resume_keyword_second": ""}}

View File

@ -3,3 +3,5 @@ $("ul.area-list > span > li:not(:has(a))").remove();
// description row. // description row.
$("ul.area-list > li:not(:has(a))").remove(); $("ul.area-list > li:not(:has(a))").remove();
$("footer").remove(); $("footer").remove();

View File

@ -107,6 +107,48 @@ function tixcraft_area_main(settings) {
} }
} }
async function do_reload_if_not_overheat(settings) {
let auto_reload_page_interval = settings.advanced.auto_reload_page_interval;
const auto_reload_overheat_count = settings.advanced.auto_reload_overheat_count;
const auto_reload_overheat_cd = settings.advanced.auto_reload_overheat_cd;
chrome.storage.local.get('last_reload_timestamp', function(items) {
if (items.last_reload_timestamp) {
let new_timestamp = [];
const now = new Date().getTime();
const overheat_second = 2.5;
//for (let i = items.last_reload_timestamp.length - 1; i >= 0; i--) {
for (let i = 0; i < items.last_reload_timestamp.length; i++) {
let each_time = items.last_reload_timestamp[i];
let current_diff = now - each_time;
if (current_diff <= overheat_second * 1000) {
//last_reload_timestamp.splice(i, 1);
new_timestamp.push(each_time);
}
}
if(new_timestamp.length >= auto_reload_overheat_count) {
console.log("overheat, slow down!");
auto_reload_page_interval = auto_reload_overheat_cd;
}
new_timestamp.push(now);
chrome.storage.local.set({
last_reload_timestamp: new_timestamp
});
//const rootElement = document.documentElement;
//rootElement.remove();
if(auto_reload_page_interval == 0) {
//console.log('Start to reload now.');
location.reload();
} else {
//console.log('We are going to reload after few seconeds.');
setTimeout(function () {
location.reload();
}, auto_reload_page_interval * 1000);
}
}
});
}
function area_auto_reload() function area_auto_reload()
{ {
let reload=false; let reload=false;
@ -120,20 +162,8 @@ function area_auto_reload()
} }
if(reload) { if(reload) {
let auto_reload_page_interval = 0.0;
if(settings) { if(settings) {
auto_reload_page_interval = settings.advanced.auto_reload_page_interval; do_reload_if_not_overheat(settings);
}
const rootElement = document.documentElement;
rootElement.remove();
if(auto_reload_page_interval == 0) {
//console.log('Start to reload now.');
location.reload();
} else {
console.log('We are going to reload after few seconeds.');
setTimeout(function () {
location.reload();
}, auto_reload_page_interval * 1000);
} }
} }
} }

View File

@ -91,6 +91,48 @@ function date_main(settings)
}, 200); }, 200);
} }
async function do_reload_if_not_overheat(settings) {
let auto_reload_page_interval = settings.advanced.auto_reload_page_interval;
const auto_reload_overheat_count = settings.advanced.auto_reload_overheat_count;
const auto_reload_overheat_cd = settings.advanced.auto_reload_overheat_cd;
chrome.storage.local.get('last_reload_timestamp', function(items) {
if (items.last_reload_timestamp) {
let new_timestamp = [];
const now = new Date().getTime();
const overheat_second = 2.5;
//for (let i = items.last_reload_timestamp.length - 1; i >= 0; i--) {
for (let i = 0; i < items.last_reload_timestamp.length; i++) {
let each_time = items.last_reload_timestamp[i];
let current_diff = now - each_time;
if (current_diff <= overheat_second * 1000) {
//last_reload_timestamp.splice(i, 1);
new_timestamp.push(each_time);
}
}
if(new_timestamp.length >= auto_reload_overheat_count) {
console.log("overheat, slow down!");
auto_reload_page_interval = auto_reload_overheat_cd;
}
new_timestamp.push(now);
chrome.storage.local.set({
last_reload_timestamp: new_timestamp
});
//const rootElement = document.documentElement;
//rootElement.remove();
if(auto_reload_page_interval == 0) {
//console.log('Start to reload now.');
location.reload();
} else {
//console.log('We are going to reload after few seconeds.');
setTimeout(function () {
location.reload();
}, auto_reload_page_interval * 1000);
}
}
});
}
function date_auto_reload() function date_auto_reload()
{ {
let reload=false; let reload=false;
@ -118,20 +160,8 @@ function date_auto_reload()
} }
if(reload) { if(reload) {
let auto_reload_page_interval = 0.0;
if(settings) { if(settings) {
auto_reload_page_interval = settings.advanced.auto_reload_page_interval; do_reload_if_not_overheat(settings);
}
const rootElement = document.documentElement;
rootElement.remove();
if(auto_reload_page_interval == 0) {
//console.log('Start to reload now.');
location.reload();
} else {
console.log('We are going to reload after few seconeds.');
setTimeout(function () {
location.reload();
}, auto_reload_page_interval * 1000);
} }
} }
} }

View File

@ -478,5 +478,5 @@
} }
], ],
"version": "1.0.27" "version": "1.0.28"
} }

View File

@ -160,6 +160,25 @@
</div> </div>
</div> </div>
<div class="row mb-3">
<label for="auto_reload_overheat_count" class="col-sm-2 col-form-label">每2.5秒最多可以刷新次數</label>
<div class="col-sm-10">
<input class="form-control" id="auto_reload_overheat_count" value="" />
<div class="bd-callout bd-callout-info">
<strong>提示:</strong>
目前只有拓元的「日期頁面」與「票價頁面」有支援這個功能。
</div>
</div>
</div>
<div class="row mb-3">
<label for="auto_reload_overheat_cd" class="col-sm-2 col-form-label">達成最多刷新次數的冷確時間(秒)</label>
<div class="col-sm-10">
<input class="form-control" id="auto_reload_overheat_cd" value="" />
</div>
</div>
<div class="row mb-3"> <div class="row mb-3">
<label class="col-sm-2 col-form-label form-check-label" for="auto_press_next_step_button">KKTIX點選下一步按鈕</label> <label class="col-sm-2 col-form-label form-check-label" for="auto_press_next_step_button">KKTIX點選下一步按鈕</label>
<div class="col-sm-10"> <div class="col-sm-10">

View File

@ -8,6 +8,8 @@ const area_select_mode = document.querySelector('#area_select_mode');
const area_keyword = document.querySelector('#area_keyword'); const area_keyword = document.querySelector('#area_keyword');
const keyword_exclude = document.querySelector('#keyword_exclude'); const keyword_exclude = document.querySelector('#keyword_exclude');
const auto_reload_page_interval = document.querySelector('#auto_reload_page_interval'); const auto_reload_page_interval = document.querySelector('#auto_reload_page_interval');
const auto_reload_overheat_count = document.querySelector('#auto_reload_overheat_count');
const auto_reload_overheat_cd = document.querySelector('#auto_reload_overheat_cd');
const auto_press_next_step_button = document.querySelector('#auto_press_next_step_button'); const auto_press_next_step_button = document.querySelector('#auto_press_next_step_button');
const max_dwell_time = document.querySelector('#max_dwell_time'); const max_dwell_time = document.querySelector('#max_dwell_time');
const disable_adjacent_seat = document.querySelector('#disable_adjacent_seat'); const disable_adjacent_seat = document.querySelector('#disable_adjacent_seat');
@ -59,9 +61,12 @@ async function saveChanges()
settings.keyword_exclude = keyword_exclude.value; settings.keyword_exclude = keyword_exclude.value;
settings.advanced.auto_reload_page_interval = auto_reload_page_interval.value;
settings.kktix.auto_press_next_step_button = auto_press_next_step_button.checked; settings.kktix.auto_press_next_step_button = auto_press_next_step_button.checked;
settings.kktix.max_dwell_time = max_dwell_time.value; settings.kktix.max_dwell_time = parseInt(max_dwell_time.value);
settings.advanced.auto_reload_page_interval = Number(auto_reload_page_interval.value);
settings.advanced.auto_reload_overheat_count = Number(auto_reload_overheat_count.value);
settings.advanced.auto_reload_overheat_cd = Number(auto_reload_overheat_cd.value);
settings.advanced.disable_adjacent_seat = disable_adjacent_seat.checked; settings.advanced.disable_adjacent_seat = disable_adjacent_seat.checked;
settings.ocr_captcha.enable = ocr_captcha_enable.checked; settings.ocr_captcha.enable = ocr_captcha_enable.checked;
@ -112,6 +117,8 @@ function loadChanges()
keyword_exclude.value = settings.keyword_exclude; keyword_exclude.value = settings.keyword_exclude;
auto_reload_page_interval.value = settings.advanced.auto_reload_page_interval; auto_reload_page_interval.value = settings.advanced.auto_reload_page_interval;
auto_reload_overheat_count.value = settings.advanced.auto_reload_overheat_count;
auto_reload_overheat_cd.value = settings.advanced.auto_reload_overheat_cd;
auto_press_next_step_button.checked = settings.kktix.auto_press_next_step_button; auto_press_next_step_button.checked = settings.kktix.auto_press_next_step_button;
max_dwell_time.value = settings.kktix.max_dwell_time; max_dwell_time.value = settings.kktix.max_dwell_time;
disable_adjacent_seat.checked = settings.advanced.disable_adjacent_seat; disable_adjacent_seat.checked = settings.advanced.disable_adjacent_seat;

View File

@ -298,6 +298,26 @@
</div> </div>
</div> </div>
<div class="row mb-3">
<label for="auto_reload_overheat_count" class="col-sm-2 col-form-label">每2.5秒最多可以刷新次數</label>
<div class="col-sm-10">
<input class="form-control" id="auto_reload_overheat_count" value="" />
<div class="bd-callout bd-callout-info">
<strong>提示:</strong>
目前只有拓元的「日期頁面」與「票價頁面」有支援這個功能。
</div>
</div>
</div>
<div class="row mb-3">
<label for="auto_reload_overheat_cd" class="col-sm-2 col-form-label">達成最多刷新次數的冷確時間(秒)</label>
<div class="col-sm-10">
<input class="form-control" id="auto_reload_overheat_cd" value="" />
</div>
</div>
<div class="row mb-3"> <div class="row mb-3">
<label for="reset_browser_interval" class="col-sm-2 col-form-label">重新啟動瀏覽器間隔(秒)</label> <label for="reset_browser_interval" class="col-sm-2 col-form-label">重新啟動瀏覽器間隔(秒)</label>
<div class="col-sm-10"> <div class="col-sm-10">

View File

@ -29,6 +29,8 @@ const max_dwell_time = document.querySelector('#max_dwell_time');
const cityline_queue_retry = document.querySelector('#cityline_queue_retry'); const cityline_queue_retry = document.querySelector('#cityline_queue_retry');
const auto_reload_page_interval = document.querySelector('#auto_reload_page_interval'); const auto_reload_page_interval = document.querySelector('#auto_reload_page_interval');
const auto_reload_overheat_count = document.querySelector('#auto_reload_overheat_count');
const auto_reload_overheat_cd = document.querySelector('#auto_reload_overheat_cd');
const reset_browser_interval = document.querySelector('#reset_browser_interval'); const reset_browser_interval = document.querySelector('#reset_browser_interval');
const proxy_server_port = document.querySelector('#proxy_server_port'); const proxy_server_port = document.querySelector('#proxy_server_port');
const window_size = document.querySelector('#window_size'); const window_size = document.querySelector('#window_size');
@ -121,6 +123,8 @@ function load_settins_to_form(settings)
cityline_queue_retry.checked = settings.cityline.cityline_queue_retry; cityline_queue_retry.checked = settings.cityline.cityline_queue_retry;
auto_reload_page_interval.value = settings.advanced.auto_reload_page_interval; auto_reload_page_interval.value = settings.advanced.auto_reload_page_interval;
auto_reload_overheat_count.value = settings.advanced.auto_reload_overheat_count;
auto_reload_overheat_cd.value = settings.advanced.auto_reload_overheat_cd;
reset_browser_interval.value = settings.advanced.reset_browser_interval; reset_browser_interval.value = settings.advanced.reset_browser_interval;
proxy_server_port.value = settings.advanced.proxy_server_port; proxy_server_port.value = settings.advanced.proxy_server_port;
window_size.value = settings.advanced.window_size; window_size.value = settings.advanced.window_size;
@ -329,6 +333,9 @@ function save_changes_to_dict(silent_flag)
if(date_keyword_string.indexOf('"')==-1) { if(date_keyword_string.indexOf('"')==-1) {
date_keyword_string = '"' + date_keyword_string + '"'; date_keyword_string = '"' + date_keyword_string + '"';
} }
if(date_keyword_string=='""') {
date_keyword_string='';
}
settings.date_auto_select.date_keyword = date_keyword_string; settings.date_auto_select.date_keyword = date_keyword_string;
settings.area_auto_select.mode = area_select_mode.value; settings.area_auto_select.mode = area_select_mode.value;
@ -337,6 +344,9 @@ function save_changes_to_dict(silent_flag)
if(area_keyword_string.indexOf('"')==-1) { if(area_keyword_string.indexOf('"')==-1) {
area_keyword_string = '"' + area_keyword_string + '"'; area_keyword_string = '"' + area_keyword_string + '"';
} }
if(area_keyword_string=='""') {
area_keyword_string='';
}
settings.area_auto_select.area_keyword = area_keyword_string; settings.area_auto_select.area_keyword = area_keyword_string;
settings.keyword_exclude = keyword_exclude.value; settings.keyword_exclude = keyword_exclude.value;
@ -354,8 +364,9 @@ function save_changes_to_dict(silent_flag)
settings.cityline.cityline_queue_retry = cityline_queue_retry.checked; settings.cityline.cityline_queue_retry = cityline_queue_retry.checked;
settings.advanced.auto_reload_page_interval = Number(auto_reload_page_interval.value); settings.advanced.auto_reload_page_interval = Number(auto_reload_page_interval.value);
settings.advanced.auto_reload_overheat_count = Number(auto_reload_overheat_count.value);
settings.advanced.auto_reload_overheat_cd = Number(auto_reload_overheat_cd.value);
settings.advanced.reset_browser_interval = parseInt(reset_browser_interval.value); settings.advanced.reset_browser_interval = parseInt(reset_browser_interval.value);
settings.advanced.proxy_server_port = proxy_server_port.value; settings.advanced.proxy_server_port = proxy_server_port.value;
settings.advanced.window_size = window_size.value; settings.advanced.window_size = window_size.value;
@ -385,6 +396,9 @@ function save_changes_to_dict(silent_flag)
if(user_guess_string_string.indexOf('"')==-1) { if(user_guess_string_string.indexOf('"')==-1) {
user_guess_string_string = '"' + user_guess_string_string + '"'; user_guess_string_string = '"' + user_guess_string_string + '"';
} }
if(user_guess_string_string=='""') {
user_guess_string_string='';
}
settings.advanced.user_guess_string = user_guess_string_string; settings.advanced.user_guess_string = user_guess_string_string;
// auto fill // auto fill
@ -416,6 +430,8 @@ function save_changes_to_dict(silent_flag)
settings.advanced.resume_keyword = resume_keyword.value; settings.advanced.resume_keyword = resume_keyword.value;
settings.advanced.idle_keyword_second = idle_keyword_second.value; settings.advanced.idle_keyword_second = idle_keyword_second.value;
settings.advanced.resume_keyword_second = resume_keyword_second.value; settings.advanced.resume_keyword_second = resume_keyword_second.value;
} }
if(!silent_flag) { if(!silent_flag) {
message('已存檔'); message('已存檔');
@ -524,6 +540,8 @@ function check_unsaved_fields()
"user_guess_string", "user_guess_string",
"remote_url", "remote_url",
"auto_reload_page_interval", "auto_reload_page_interval",
"auto_reload_overheat_count",
"auto_reload_overheat_cd",
"reset_browser_interval", "reset_browser_interval",
"proxy_server_port", "proxy_server_port",
"window_size", "window_size",