allow to sendkeys vis javascript to localhost.
parent
7d6ff4330f
commit
8142d85ddc
|
@ -52,7 +52,6 @@ CONST_MAXBOT_EXTENSION_NAME = "Maxbotplus_1.0.0"
|
|||
CONST_MAXBOT_INT28_FILE = "MAXBOT_INT28_IDLE.txt"
|
||||
CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.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_FILTER =[
|
||||
"*.doubleclick.net/*",
|
||||
|
@ -10868,11 +10867,19 @@ def check_refresh_datetime_occur(driver, target_time):
|
|||
return is_refresh_datetime_sent
|
||||
|
||||
def sendkey_to_browser(driver, config_dict):
|
||||
all_command_done = True
|
||||
tmp_filepath = ""
|
||||
if "token" in config_dict:
|
||||
app_root = util.get_app_root()
|
||||
tmp_file = config_dict["token"] + ".tmp"
|
||||
tmp_filepath = os.path.join(app_root, tmp_file)
|
||||
|
||||
if os.path.exists(tmp_filepath):
|
||||
sendkey_to_browser_exist(driver, tmp_filepath)
|
||||
|
||||
def sendkey_to_browser_exist(driver, tmp_filepath):
|
||||
sendkey_dict = None
|
||||
try:
|
||||
with open(CONST_MAXBOT_SENDKEY_FILE) as json_data:
|
||||
with open(tmp_filepath) as json_data:
|
||||
sendkey_dict = json.load(json_data)
|
||||
print(sendkey_dict)
|
||||
except Exception as e:
|
||||
|
@ -10880,43 +10887,43 @@ def sendkey_to_browser(driver, config_dict):
|
|||
print(e)
|
||||
pass
|
||||
|
||||
is_command_accepted = False
|
||||
if sendkey_dict:
|
||||
all_command_done = True
|
||||
if "command" in sendkey_dict:
|
||||
for cmd_dict in sendkey_dict["command"]:
|
||||
#print("cmd_dict", cmd_dict)
|
||||
if cmd_dict["token"] == config_dict["token"]:
|
||||
is_command_accepted = True
|
||||
|
||||
if cmd_dict["type"] == "sendkey":
|
||||
print("sendkey")
|
||||
try:
|
||||
form_input_1 = driver.find_element(By.CSS_SELECTOR, cmd_dict["selector"])
|
||||
if cmd_dict["type"] == "sendkey":
|
||||
print("sendkey")
|
||||
target_text = cmd_dict["text"]
|
||||
try:
|
||||
form_input_1 = driver.find_element(By.CSS_SELECTOR, cmd_dict["selector"])
|
||||
inputed_value_1 = form_input_1.get_attribute('value')
|
||||
if not inputed_value_1 == target_text:
|
||||
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
|
||||
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 is_command_accepted:
|
||||
# must all command success to delete tmp file.
|
||||
if all_command_done:
|
||||
try:
|
||||
os.unlink(CONST_MAXBOT_SENDKEY_FILE)
|
||||
os.unlink(tmp_filepath)
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
|
@ -11003,8 +11010,7 @@ def main(args):
|
|||
time.sleep(0.1)
|
||||
continue
|
||||
|
||||
if os.path.exists(CONST_MAXBOT_SENDKEY_FILE):
|
||||
sendkey_to_browser(driver, config_dict)
|
||||
sendkey_to_browser(driver, config_dict)
|
||||
|
||||
# default is 0, not reset.
|
||||
if config_dict["advanced"]["reset_browser_interval"] > 0:
|
||||
|
|
14
settings.py
14
settings.py
|
@ -48,7 +48,6 @@ CONST_MAXBOT_EXTENSION_STATUS_JSON = "status.json"
|
|||
CONST_MAXBOT_INT28_FILE = "MAXBOT_INT28_IDLE.txt"
|
||||
CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt"
|
||||
CONST_MAXBOT_QUESTION_FILE = "MAXBOT_QUESTION.txt"
|
||||
CONST_MAXBOT_SENDKEY_FILE = "MAXBOT_SENDKEY.txt"
|
||||
|
||||
CONST_SERVER_PORT = 16888
|
||||
|
||||
|
@ -381,11 +380,16 @@ def clean_tmp_file():
|
|||
,CONST_MAXBOT_INT28_FILE
|
||||
,CONST_MAXBOT_ANSWER_ONLINE_FILE
|
||||
,CONST_MAXBOT_QUESTION_FILE
|
||||
,CONST_MAXBOT_SENDKEY_FILE
|
||||
]
|
||||
for filepath in remove_file_list:
|
||||
util.force_remove_file(filepath)
|
||||
|
||||
Root_Dir = util.get_app_root()
|
||||
target_folder = os.listdir(Root_Dir)
|
||||
for item in target_folder:
|
||||
if item.endswith(".tmp"):
|
||||
os.remove(os.path.join(Root_Dir, item))
|
||||
|
||||
class QuestionHandler(tornado.web.RequestHandler):
|
||||
def get(self):
|
||||
global txt_question
|
||||
|
@ -504,8 +508,10 @@ class SendkeyHandler(tornado.web.RequestHandler):
|
|||
|
||||
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)
|
||||
if "token" in _body:
|
||||
tmp_file = _body["token"] + ".tmp"
|
||||
config_filepath = os.path.join(app_root, tmp_file)
|
||||
util.save_json(_body, config_filepath)
|
||||
|
||||
self.write({"return": True})
|
||||
|
||||
|
|
|
@ -43,7 +43,6 @@ CONST_MAXBOT_EXTENSION_STATUS_JSON = "status.json"
|
|||
CONST_MAXBOT_INT28_FILE = "MAXBOT_INT28_IDLE.txt"
|
||||
CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt"
|
||||
CONST_MAXBOT_QUESTION_FILE = "MAXBOT_QUESTION.txt"
|
||||
CONST_MAXBOT_SENDKEY_FILE = "MAXBOT_SENDKEY.txt"
|
||||
|
||||
CONST_SERVER_PORT = 16888
|
||||
|
||||
|
@ -3195,11 +3194,16 @@ def clean_tmp_file():
|
|||
,CONST_MAXBOT_INT28_FILE
|
||||
,CONST_MAXBOT_ANSWER_ONLINE_FILE
|
||||
,CONST_MAXBOT_QUESTION_FILE
|
||||
,CONST_MAXBOT_SENDKEY_FILE
|
||||
]
|
||||
for filepath in remove_file_list:
|
||||
util.force_remove_file(filepath)
|
||||
|
||||
Root_Dir = util.get_app_root()
|
||||
target_folder = os.listdir(Root_Dir)
|
||||
for item in target_folder:
|
||||
if item.endswith(".tmp"):
|
||||
os.remove(os.path.join(Root_Dir, item))
|
||||
|
||||
def btn_copy_ip_clicked():
|
||||
local_ip = util.get_ip_address()
|
||||
ip_address = "http://%s:%d/" % (local_ip,CONST_SERVER_PORT)
|
||||
|
@ -3271,8 +3275,10 @@ class SendkeyHandler(tornado.web.RequestHandler):
|
|||
|
||||
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)
|
||||
if "token" in _body:
|
||||
tmp_file = _body["token"] + ".tmp"
|
||||
config_filepath = os.path.join(app_root, tmp_file)
|
||||
util.save_json(_body, config_filepath)
|
||||
|
||||
self.write({"return": True})
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"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*"]}
|
||||
{"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,1", "idle_keyword": "", "resume_keyword": "", "idle_keyword_second": "", "resume_keyword_second": ""}, "token": "3fbc8123327e468b8ac6e9280cf0653a", "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*"]}
|
|
@ -1 +1 @@
|
|||
{"homepage": "https://ticket.ibon.com.tw/EventBuy/B078PBP9/B07CE700/B07CE705", "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": ""}, "token": "e08a643a0133424bb7cdc123b47c7857"}
|
||||
{"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,1", "idle_keyword": "", "resume_keyword": "", "idle_keyword_second": "", "resume_keyword_second": ""}, "token": "3fbc8123327e468b8ac6e9280cf0653a"}
|
|
@ -111,24 +111,27 @@ function ibon_set_ocr_answer(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, token: settings.token},
|
||||
{type: 'click', selector: 'div#ticket-wrap a.btn.btn-primary[href]', token: settings.token}
|
||||
]};
|
||||
body = JSON.stringify(body);
|
||||
if(api_url.indexOf("127.0.0.")>-1) {
|
||||
let body = {
|
||||
token: settings.token,
|
||||
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 = {
|
||||
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);
|
||||
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) {
|
||||
|
|
Loading…
Reference in New Issue