2024-04-24, set auto_guess_options default to Fasle, and allow to set on web GUI.

master
Your Name 2024-09-04 11:46:02 +08:00
parent 312a26b84e
commit cf444bc2e2
18 changed files with 463 additions and 96 deletions

View File

@ -44,7 +44,7 @@ except Exception as exc:
print(exc) print(exc)
pass pass
CONST_APP_VERSION = "MaxBot (2024.04.23)" CONST_APP_VERSION = "MaxBot (2024.04.24)"
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"
@ -52,6 +52,7 @@ CONST_MAXBOT_EXTENSION_NAME = "Maxbotplus_1.0.0"
CONST_MAXBOT_INT28_FILE = "MAXBOT_INT28_IDLE.txt" CONST_MAXBOT_INT28_FILE = "MAXBOT_INT28_IDLE.txt"
CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt" CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt"
CONST_MAXBOT_QUESTION_FILE = "MAXBOT_QUESTION.txt" CONST_MAXBOT_QUESTION_FILE = "MAXBOT_QUESTION.txt"
CONST_MAXBOT_SENDKEY_FILE = "MAXBOT_SENDKEY.txt"
CONST_MAXBLOCK_EXTENSION_NAME = "Maxblockplus_1.0.0" CONST_MAXBLOCK_EXTENSION_NAME = "Maxblockplus_1.0.0"
CONST_MAXBLOCK_EXTENSION_FILTER =[ CONST_MAXBLOCK_EXTENSION_FILTER =[
"*.doubleclick.net/*", "*.doubleclick.net/*",
@ -10866,6 +10867,54 @@ def check_refresh_datetime_occur(driver, target_time):
return is_refresh_datetime_sent return is_refresh_datetime_sent
def sendkey_to_browser(driver):
all_command_done = True
sendkey_dict = None
try:
with open(CONST_MAXBOT_SENDKEY_FILE) as json_data:
sendkey_dict = json.load(json_data)
print(sendkey_dict)
#os.unlink(CONST_MAXBOT_SENDKEY_FILE)
except Exception as e:
print("error on open file")
print(e)
pass
if sendkey_dict:
if "command" in sendkey_dict:
for cmd_dict in sendkey_dict["command"]:
print("cmd_dict", cmd_dict)
if cmd_dict["type"] == "sendkey":
print("sendkey")
try:
form_input_1 = driver.find_element(By.CSS_SELECTOR, cmd_dict["selector"])
form_input_1.clear()
form_input_1.click()
form_input_1.send_keys(cmd_dict["text"])
except Exception as exc:
all_command_done = False
print("error on sendkey")
print(exc)
pass
if cmd_dict["type"] == "click":
print("click")
try:
form_input_1 = driver.find_element(By.CSS_SELECTOR, cmd_dict["selector"])
form_input_1.click()
except Exception as exc:
all_command_done = False
print("error on click")
print(exc)
pass
time.sleep(0.05)
if all_command_done:
try:
os.unlink(CONST_MAXBOT_SENDKEY_FILE)
except Exception as e:
pass
def main(args): def main(args):
config_dict = get_config_dict(args) config_dict = get_config_dict(args)
@ -10948,6 +10997,9 @@ def main(args):
time.sleep(0.1) time.sleep(0.1)
continue continue
if os.path.exists(CONST_MAXBOT_SENDKEY_FILE):
sendkey_to_browser(driver)
if config_dict["advanced"]["reset_browser_interval"] > 0: if config_dict["advanced"]["reset_browser_interval"] > 0:
maxbot_running_time = time.time() - maxbot_last_reset_time maxbot_running_time = time.time() - maxbot_last_reset_time
if maxbot_running_time > config_dict["advanced"]["reset_browser_interval"]: if maxbot_running_time > config_dict["advanced"]["reset_browser_interval"]:

View File

@ -24,7 +24,7 @@ import webbrowser
import util import util
CONST_APP_VERSION = "MaxBot (2024.04.23)" CONST_APP_VERSION = "MaxBot (2024.04.24)"
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.23)" CONST_APP_VERSION = "MaxBot (2024.04.24)"
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

@ -1,7 +1,7 @@
{ {
"homepage": "about:blank", "homepage": "about:blank",
"browser": "chrome", "browser": "chrome",
"language": "\u7e41\u9ad4\u4e2d\u6587", "language": "English",
"ticket_number": 2, "ticket_number": 2,
"refresh_datetime": "", "refresh_datetime": "",
"ocr_captcha": { "ocr_captcha": {
@ -25,7 +25,7 @@
"kktix": { "kktix": {
"auto_press_next_step_button": true, "auto_press_next_step_button": true,
"auto_fill_ticket_number": true, "auto_fill_ticket_number": true,
"max_dwell_time": 60 "max_dwell_time": 90
}, },
"cityline": { "cityline": {
"cityline_queue_retry": true "cityline_queue_retry": true
@ -78,12 +78,12 @@
"block_facebook_network": false, "block_facebook_network": false,
"headless": false, "headless": false,
"verbose": false, "verbose": false,
"auto_guess_options": true, "auto_guess_options": false,
"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_count": 4,
"auto_reload_overheat_cd": 1.0, "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.23)" CONST_APP_VERSION = "MaxBot (2024.04.24)"
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"
@ -48,6 +48,7 @@ CONST_MAXBOT_EXTENSION_STATUS_JSON = "status.json"
CONST_MAXBOT_INT28_FILE = "MAXBOT_INT28_IDLE.txt" CONST_MAXBOT_INT28_FILE = "MAXBOT_INT28_IDLE.txt"
CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt" CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt"
CONST_MAXBOT_QUESTION_FILE = "MAXBOT_QUESTION.txt" CONST_MAXBOT_QUESTION_FILE = "MAXBOT_QUESTION.txt"
CONST_MAXBOT_SENDKEY_FILE = "MAXBOT_SENDKEY.txt"
CONST_SERVER_PORT = 16888 CONST_SERVER_PORT = 16888
@ -127,7 +128,7 @@ def get_default_config():
config_dict['kktix']={} config_dict['kktix']={}
config_dict["kktix"]["auto_press_next_step_button"] = True config_dict["kktix"]["auto_press_next_step_button"] = True
config_dict["kktix"]["auto_fill_ticket_number"] = True config_dict["kktix"]["auto_fill_ticket_number"] = True
config_dict["kktix"]["max_dwell_time"] = 60 config_dict["kktix"]["max_dwell_time"] = 90
config_dict['cityline']={} config_dict['cityline']={}
config_dict["cityline"]["cityline_queue_retry"] = True config_dict["cityline"]["cityline_queue_retry"] = True
@ -185,7 +186,7 @@ def get_default_config():
config_dict["advanced"]["headless"] = False config_dict["advanced"]["headless"] = False
config_dict["advanced"]["verbose"] = False config_dict["advanced"]["verbose"] = False
config_dict["advanced"]["auto_guess_options"] = True config_dict["advanced"]["auto_guess_options"] = False
config_dict["advanced"]["user_guess_string"] = "" config_dict["advanced"]["user_guess_string"] = ""
# remote_url not under ocr, due to not only support ocr features. # remote_url not under ocr, due to not only support ocr features.
@ -380,6 +381,7 @@ def clean_tmp_file():
,CONST_MAXBOT_INT28_FILE ,CONST_MAXBOT_INT28_FILE
,CONST_MAXBOT_ANSWER_ONLINE_FILE ,CONST_MAXBOT_ANSWER_ONLINE_FILE
,CONST_MAXBOT_QUESTION_FILE ,CONST_MAXBOT_QUESTION_FILE
,CONST_MAXBOT_SENDKEY_FILE
] ]
for filepath in remove_file_list: for filepath in remove_file_list:
util.force_remove_file(filepath) util.force_remove_file(filepath)
@ -479,6 +481,34 @@ class SaveJsonHandler(tornado.web.RequestHandler):
self.finish() self.finish()
class SendkeyHandler(tornado.web.RequestHandler):
def post(self):
self.set_header("Access-Control-Allow-Origin", "*")
self.set_header("Access-Control-Allow-Headers", "x-requested-with")
self.set_header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS')
_body = None
is_pass_check = True
errorMessage = ""
errorCode = 0
if is_pass_check:
is_pass_check = False
try :
_body = json.loads(self.request.body)
is_pass_check = True
except Exception:
errorMessage = "wrong json format"
errorCode = 1001
pass
if is_pass_check:
app_root = util.get_app_root()
config_filepath = os.path.join(app_root, CONST_MAXBOT_SENDKEY_FILE)
util.save_json(_body, config_filepath)
self.write({"return": True})
class OcrHandler(tornado.web.RequestHandler): class OcrHandler(tornado.web.RequestHandler):
def get(self): def get(self):
self.write({"answer": "1234"}) self.write({"answer": "1234"})
@ -560,6 +590,7 @@ async def main_server():
app = Application([ app = Application([
("/version", VersionHandler), ("/version", VersionHandler),
("/shutdown", ShutdownHandler), ("/shutdown", ShutdownHandler),
("/sendkey", SendkeyHandler),
# status api # status api
("/status", StatusHandler), ("/status", StatusHandler),

View File

@ -34,7 +34,7 @@ try:
except Exception as exc: except Exception as exc:
pass pass
CONST_APP_VERSION = "MaxBot (2024.04.23)" CONST_APP_VERSION = "MaxBot (2024.04.24)"
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"
@ -43,6 +43,7 @@ CONST_MAXBOT_EXTENSION_STATUS_JSON = "status.json"
CONST_MAXBOT_INT28_FILE = "MAXBOT_INT28_IDLE.txt" CONST_MAXBOT_INT28_FILE = "MAXBOT_INT28_IDLE.txt"
CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt" CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt"
CONST_MAXBOT_QUESTION_FILE = "MAXBOT_QUESTION.txt" CONST_MAXBOT_QUESTION_FILE = "MAXBOT_QUESTION.txt"
CONST_MAXBOT_SENDKEY_FILE = "MAXBOT_SENDKEY.txt"
CONST_SERVER_PORT = 16888 CONST_SERVER_PORT = 16888
@ -618,7 +619,7 @@ def get_default_config():
config_dict['kktix']={} config_dict['kktix']={}
config_dict["kktix"]["auto_press_next_step_button"] = True config_dict["kktix"]["auto_press_next_step_button"] = True
config_dict["kktix"]["auto_fill_ticket_number"] = True config_dict["kktix"]["auto_fill_ticket_number"] = True
config_dict["kktix"]["max_dwell_time"] = 60 config_dict["kktix"]["max_dwell_time"] = 90
config_dict['cityline']={} config_dict['cityline']={}
config_dict["cityline"]["cityline_queue_retry"] = True config_dict["cityline"]["cityline_queue_retry"] = True
@ -676,7 +677,7 @@ def get_default_config():
config_dict["advanced"]["headless"] = False config_dict["advanced"]["headless"] = False
config_dict["advanced"]["verbose"] = False config_dict["advanced"]["verbose"] = False
config_dict["advanced"]["auto_guess_options"] = True config_dict["advanced"]["auto_guess_options"] = False
config_dict["advanced"]["user_guess_string"] = "" config_dict["advanced"]["user_guess_string"] = ""
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)
@ -3194,6 +3195,7 @@ def clean_tmp_file():
,CONST_MAXBOT_INT28_FILE ,CONST_MAXBOT_INT28_FILE
,CONST_MAXBOT_ANSWER_ONLINE_FILE ,CONST_MAXBOT_ANSWER_ONLINE_FILE
,CONST_MAXBOT_QUESTION_FILE ,CONST_MAXBOT_QUESTION_FILE
,CONST_MAXBOT_SENDKEY_FILE
] ]
for filepath in remove_file_list: for filepath in remove_file_list:
util.force_remove_file(filepath) util.force_remove_file(filepath)
@ -3246,6 +3248,34 @@ class VersionHandler(tornado.web.RequestHandler):
def get(self): def get(self):
self.write({"version":self.application.version}) self.write({"version":self.application.version})
class SendkeyHandler(tornado.web.RequestHandler):
def post(self):
self.set_header("Access-Control-Allow-Origin", "*")
self.set_header("Access-Control-Allow-Headers", "x-requested-with")
self.set_header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS')
_body = None
is_pass_check = True
errorMessage = ""
errorCode = 0
if is_pass_check:
is_pass_check = False
try :
_body = json.loads(self.request.body)
is_pass_check = True
except Exception:
errorMessage = "wrong json format"
errorCode = 1001
pass
if is_pass_check:
app_root = util.get_app_root()
config_filepath = os.path.join(app_root, CONST_MAXBOT_SENDKEY_FILE)
util.save_json(_body, config_filepath)
self.write({"return": True})
class OcrHandler(tornado.web.RequestHandler): class OcrHandler(tornado.web.RequestHandler):
def get(self): def get(self):
self.write({"answer": "1234"}) self.write({"answer": "1234"})
@ -3305,6 +3335,8 @@ async def main_server():
app = Application([ app = Application([
("/", MainHandler), ("/", MainHandler),
("/version", VersionHandler), ("/version", VersionHandler),
("/sendkey", SendkeyHandler),
("/ocr", OcrHandler), ("/ocr", OcrHandler),
("/query", MainHandler), ("/query", MainHandler),
("/question", QuestionHandler), ("/question", QuestionHandler),

View File

@ -1 +1 @@
{"homepage": "about:blank", "browser": "chrome", "language": "\u7e41\u9ad4\u4e2d\u6587", "ticket_number": 2, "refresh_datetime": "", "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.0, "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*"]} {"homepage": "about:blank", "browser": "chrome", "language": "English", "ticket_number": 2, "refresh_datetime": "", "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": 90}, "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": false, "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,6 +153,48 @@ async function ocr(data_url, image_data, tabId)
); );
} }
async function post(data_url, post_body, tabId)
{
//console.log("data_url:"+data_url);
fetch(data_url,{
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: post_body
})
.then(response =>
{
if (response.ok)
{
return response.json();
}
else if (response.status === 404)
{
let result_json={"answer": "", "fail": 'error 404'};
//console.log(result_json);
//sendResponse(result_json);
return Promise.reject('error 404')
}
}
)
.then((data) =>
{
if (data)
{
let result_json=data;
console.log(result_json);
chrome.tabs.sendMessage(tabId, result_json);
}
}
)
.catch(error =>
{
console.log('error is', error)
}
);
}
// for avoid overheat. // for avoid overheat.
chrome.storage.local.set( chrome.storage.local.set(
{ {
@ -179,6 +221,11 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
ocr(request_json.data.url, request_json.data.image_data, tabId); ocr(request_json.data.url, request_json.data.image_data, tabId);
} }
if(request_json.action=="post") {
const tabId = sender.tab.id;
post(request_json.data.url, request_json.data.post_data, tabId);
}
if(request_json.action=="status") { if(request_json.action=="status") {
result_json={"status": answer}; result_json={"status": answer};
const tabId = sender.tab.id; const tabId = sender.tab.id;

View File

@ -1 +1 @@
{"homepage": "about:blank", "browser": "chrome", "language": "\u7e41\u9ad4\u4e2d\u6587", "ticket_number": 2, "refresh_datetime": "", "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.0, "reset_browser_interval": 0, "proxy_server_port": "", "window_size": "480,1024,0", "idle_keyword": "", "resume_keyword": "", "idle_keyword_second": "", "resume_keyword_second": ""}} {"homepage": "about:blank", "browser": "chrome", "language": "English", "ticket_number": 2, "refresh_datetime": "", "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": 90}, "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": false, "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

@ -0,0 +1,215 @@
const storage = chrome.storage.local;
var settings = null;
$("footer").remove();
function ibon_assign_ticket_number(ticket_number) {
let $main_table = $("div > table.table[id] > tbody");
if ($main_table.length > 0) {
//console.log("found main table");
let $ticket_tr = $main_table.find("tr");
if ($ticket_tr.length) {
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);
$(this).trigger("change");
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);
$ticket_options.trigger("change");
is_ticket_number_assign = true;
}
if (is_ticket_number_assign) {
let select_tag = document.querySelector("div > table.table[id] > tbody select");
if(select_tag) {
//console.log("trigger select click");
select_tag.dispatchEvent(new Event('change'));
}
start_ibon_ocr();
}
} else {
//console.log("target option empty");
}
} else {
setTimeout(function() {
ibon_assign_ticket_number(ticket_number)
}, 200);
}
}
}
function ibon_assign_adjacent_seat(flag) {
//console.log("disable_adjacent_seat flag:"+flag);
if (flag) {
$('input[type=checkbox]').each(function() {
$(this).prop('checked', true);
});
}
}
function ibon_focus_on_captcha() {
$("div.editor-box > div > input[type='text']").focus();
}
var myInterval = null;
function ibon_get_ocr_image() {
//console.log("get_ocr_image");
let image_data = "";
// PS: tixcraft have different domain to use the same content script.
const currentUrl = window.location.href;
const domain = currentUrl.split('/')[2];
let canvas = document.querySelector("div.editor-box > div > canvas");
if (canvas != null) {
let img_data = canvas.toDataURL();
if (img_data) {
image_data = img_data.split(",")[1];
//console.log(image_data);
}
}
return image_data;
}
chrome.runtime.onMessage.addListener((message) => {
//console.log('sent from background', message);
if(message.answer) {
ibon_set_ocr_answer(message.answer);
}
});
function ibon_set_ocr_answer(answer) {
console.log("answer:" + answer);
if (answer.length > 0) {
//$("div.editor-box > div > input[type='text']").val(answer);
let input_tag = document.querySelector("div.editor-box > div > input[type='text']");
if(input_tag) {
//console.log("click on captcha input.")
//input_tag.click();
//input_tag.value=answer;
//input_tag.dispatchEvent(new Event('change'));
if(input_tag.value != answer) {
console.log("set new answer as:" + answer);
ibon_set_ocr_answer_api(answer);
}
}
}
}
async function ibon_set_ocr_answer_api(answer) {
let api_url = get_remote_url(settings);
let body = {
command: [
{type: 'sendkey', selector: "div.editor-box > div > input[type='text']", text: answer},
{type: 'click', selector: 'div#ticket-wrap a.btn.btn-primary[href]'}
]};
body = JSON.stringify(body);
let bundle = {
action: 'post',
data: {
'url': api_url + 'sendkey',
'post_data': body,
}
};
let bundle_string = JSON.stringify(bundle);
const return_answer = await chrome.runtime.sendMessage(bundle);
//console.log(return_answer);
}
async function ibon_get_ocr_answer(api_url, image_data) {
let bundle = {
action: 'ocr',
data: {
'url': api_url + 'ocr',
'image_data': image_data,
}
};
let bundle_string = JSON.stringify(bundle);
const return_answer = await chrome.runtime.sendMessage(bundle);
//console.log(return_answer);
}
function ibon_orc_image_ready(api_url) {
let ret = false;
let image_data = ibon_get_ocr_image();
if (image_data.length > 0) {
ret = true;
if (myInterval) clearInterval(myInterval);
ibon_get_ocr_answer(api_url, image_data);
}
console.log("ibon_orc_image_ready:" + ret);
return ret;
}
storage.get('settings', function(items) {
if (items.settings) {
settings = items.settings;
} else {
console.log('no settings found');
}
});
storage.get('settings', function(items) {
if (items.settings) {
settings = items.settings;
}
});
function get_remote_url(settings) {
let remote_url_string = "";
if (settings) {
let remote_url_array = [];
if (settings.advanced.remote_url.length > 0) {
remote_url_array = JSON.parse('[' + settings.advanced.remote_url + ']');
}
if (remote_url_array.length) {
remote_url_string = remote_url_array[0];
}
}
return remote_url_string;
}
function start_ibon_ocr() {
// ocr
if (settings.ocr_captcha.enable) {
let remote_url_string = get_remote_url(settings);
if (!ibon_orc_image_ready(remote_url_string)) {
myInterval = setInterval(() => {
ibon_orc_image_ready(remote_url_string);
}, 100);
}
} else {
// no orc, just focus;
ibon_focus_on_captcha();
}
}
storage.get('status', function(items) {
if (items.status && items.status == 'ON') {
//console.log("ticket_number:"+ settings.ticket_number);
// ajax.
setTimeout(function() {
ibon_assign_ticket_number(settings.ticket_number);
ibon_assign_adjacent_seat(settings.advanced.disable_adjacent_seat);
}, 100);
} else {
console.log('no status found');
}
});

View File

@ -1,5 +1,4 @@
var myInterval = null; var myInterval = null;
function dom_ready() function dom_ready()
{ {
let ret=false; let ret=false;
@ -8,15 +7,29 @@ function dom_ready()
ret=true; ret=true;
if(myInterval) clearInterval(myInterval); if(myInterval) clearInterval(myInterval);
(function () { (function () {
$("div#ticket-wrap a[onclick]").click(); var btn_e = document.createEvent('MouseEvents');
btn_e.initEvent('click', true, true );
let btn1 = document.querySelector("div#ticket-wrap > a[onclick]");
if(btn1 > 0) {
console.log("trigger btn1 click");
//btn1.click();
let btn1 = document.querySelector("div#ticket-wrap > a[onclick]");
btn1.dispatchEvent(btn_e);
} else {
let btn2 = document.querySelector("div#ticket-wrap > a[href]");
if(btn2) {
console.log("trigger btn2 click");
//btn2.click();
btn2.dispatchEvent(btn_e);
}
}
})(); })();
} }
//console.log("dom_ready:"+ret); console.log("dom_ready:"+ret);
return ret; return ret;
} }
if(!dom_ready()) { myInterval = setInterval(() => {
myInterval = setInterval(() => { dom_ready();
dom_ready(); }, 1000);
}, 100);
}

View File

@ -1,8 +1,5 @@
const storage = chrome.storage.local; const storage = chrome.storage.local;
$("div.description").remove();
$("footer").remove();
function kktix_event_redirect() function kktix_event_redirect()
{ {
const currentUrl = window.location.href; const currentUrl = window.location.href;

View File

@ -1,5 +0,0 @@
$("div.headlines").remove();
$("section.app-intro").remove();
$("section.copywriting").remove();
$("section.partner-venues").remove();
$("footer").remove();

View File

@ -1,6 +1,4 @@
var myInterval = null; var myInterval = null;
var checkboxInterval = null;
//console.log("assign appear");
function kktix_verification_conditions(settings) function kktix_verification_conditions(settings)
{ {
@ -35,14 +33,6 @@ function kktix_verification_conditions(settings)
return is_text_sent; return is_text_sent;
} }
function kktix_agree()
{
$('input[type=checkbox]:not(:checked)').each(function() {
$(this).click();
if(checkboxInterval) clearInterval(checkboxInterval);
});
}
function kktix_area_keyword(settings) function kktix_area_keyword(settings)
{ {
let area_keyword_array = []; let area_keyword_array = [];
@ -91,20 +81,6 @@ function kktix_area_keyword(settings)
let ticket_number = settings.ticket_number; let ticket_number = settings.ticket_number;
if(ticket_number>0) { if(ticket_number>0) {
/*
// trigger events by jQuery.
let target_input = target_area.find("input");
target_input.click();
target_input.prop("value", ticket_number);
let down = $.Event('keydown');
down.key=""+ticket_number;
target_input.trigger(down);
let up = $.Event('keyup');
up.key=""+ticket_number;
target_input.trigger(up);
*/
//console.log(base_info); //console.log(base_info);
let is_verification_conditions_popup = false; let is_verification_conditions_popup = false;
@ -176,20 +152,8 @@ function dom_ready()
return ret; return ret;
} }
const rootElement = document.documentElement; if(!dom_ready()) {
if(rootElement) { myInterval = setInterval(() => {
if(!dom_ready()) { dom_ready();
myInterval = setInterval(() => { }, 200);
dom_ready();
}, 200);
checkboxInterval= setInterval(() => {
//console.log("kktix_agree")
kktix_agree();
}, 200);
}
$("footer").remove();
$("div.banner-wrapper div.img-wrapper img").remove();
} }

View File

@ -1,6 +1,19 @@
const storage = chrome.storage.local; const storage = chrome.storage.local;
var settings = null; var settings = null;
var myInterval = null; var checkboxInterval = null;
var notNowInterval = null;
function kktix_agree()
{
$('input[type=checkbox]:not(:checked)').each(function() {
$(this).click();
});
}
function kktix_not_now()
{
$("#guestModal.modal.in > div.modal-dialog > div > div.modal-footer > button.btn-default.pull-right").click();
}
function kktix_clean_exclude(settings) function kktix_clean_exclude(settings)
{ {
@ -42,7 +55,7 @@ function kktix_force_auto_reload_by_timer()
if(max_dwell_time <= 10) { if(max_dwell_time <= 10) {
max_dwell_time = 10; max_dwell_time = 10;
} }
console.log('We are going to force reload after few seconeds.'); console.log('We are going to force reload after '+ max_dwell_time +' seconeds.');
setTimeout(function () { setTimeout(function () {
location.reload(); location.reload();
}, max_dwell_time * 1000); }, max_dwell_time * 1000);
@ -62,6 +75,13 @@ storage.get('status', function (items)
{ {
if (items.status && items.status=='ON') if (items.status && items.status=='ON')
{ {
checkboxInterval = setInterval(() => {
kktix_agree();
}, 100);
notNowInterval = setInterval(() => {
kktix_not_now();
}, 200);
kktix_force_auto_reload_by_timer(); kktix_force_auto_reload_by_timer();
setTimeout(function () { setTimeout(function () {

View File

@ -291,6 +291,16 @@
"js/ibon_ticket_next.js" "js/ibon_ticket_next.js"
] ]
}, },
{
"matches": [
"https://ticket.ibon.com.tw/EventBuy/*/*/*"
],
"run_at": "document_end",
"js": [
"jquery.min.js",
"js/ibon_eventbuy.js"
]
},
{ {
"matches": [ "matches": [
"https://orders.ibon.com.tw/application/utk02/UTK0201_0.aspx?*PERFORMANCE_ID=*PRODUCT_ID=*", "https://orders.ibon.com.tw/application/utk02/UTK0201_0.aspx?*PERFORMANCE_ID=*PRODUCT_ID=*",
@ -415,16 +425,6 @@
"js/ticketplus_order.js" "js/ticketplus_order.js"
] ]
}, },
{
"matches": [
"https://kktix.com/"
],
"run_at": "document_end",
"js": [
"jquery.min.js",
"js/kktix_home.js"
]
},
{ {
"matches": [ "matches": [
"https://*.kktix.cc/events/*" "https://*.kktix.cc/events/*"
@ -435,17 +435,6 @@
"js/kktix_events.js" "js/kktix_events.js"
] ]
}, },
{
"matches": [
"https://kktix.com/events/*/registrations/new"
],
"world": "MAIN",
"run_at": "document_end",
"js": [
"js/common.js",
"js/kktix_registrations_assign.js"
]
},
{ {
"matches": [ "matches": [
"https://kktix.com/events/*/registrations/new" "https://kktix.com/events/*/registrations/new"
@ -476,7 +465,7 @@
"js/fantopia_fill.js" "js/fantopia_fill.js"
] ]
} }
], ],
"version": "1.0.28" "version": "1.0.29"
} }

View File

@ -432,6 +432,14 @@
<textarea class="form-control" id="user_guess_string" rows="3"></textarea> <textarea class="form-control" id="user_guess_string" rows="3"></textarea>
</div> </div>
</div> </div>
<div class="row mb-3">
<label class="col-sm-2 col-form-label form-check-label" for="auto_guess_options">自動猜測驗證問題</label>
<div class="col-sm-10">
<input class="form-check-input" type="checkbox" id="auto_guess_options" />
</div>
</div>
</div> </div>
<!-- tab 5 --> <!-- tab 5 -->

View File

@ -52,6 +52,7 @@ const PUBLIC_SERVER_URL = "http://maxbot.dropboxlike.com:16888/";
// dictionary // dictionary
const user_guess_string = document.querySelector('#user_guess_string'); const user_guess_string = document.querySelector('#user_guess_string');
const auto_guess_options = document.querySelector('#auto_guess_options');
// auto fill // auto fill
@ -158,6 +159,7 @@ function load_settins_to_form(settings)
if(user_guess_string.value=='""') { if(user_guess_string.value=='""') {
user_guess_string.value=''; user_guess_string.value='';
} }
auto_guess_options.checked = settings.advanced.auto_guess_options;
// auto fill // auto fill
tixcraft_sid.value = settings.advanced.tixcraft_sid; tixcraft_sid.value = settings.advanced.tixcraft_sid;
@ -405,6 +407,8 @@ function save_changes_to_dict(silent_flag)
} }
settings.advanced.user_guess_string = user_guess_string_string; settings.advanced.user_guess_string = user_guess_string_string;
settings.advanced.auto_guess_options = auto_guess_options.checked;
// auto fill // auto fill
settings.advanced.tixcraft_sid = tixcraft_sid.value; settings.advanced.tixcraft_sid = tixcraft_sid.value;
settings.advanced.ibonqware = ibonqware.value; settings.advanced.ibonqware = ibonqware.value;