2023-12-25 MaxBot settings able to stop extension.

master
unknown 2024-01-05 16:10:13 +08:00
parent cd8e852488
commit d5e942da74
9 changed files with 80 additions and 20 deletions

View File

@ -54,13 +54,15 @@ import webbrowser
import chromedriver_autoinstaller
CONST_APP_VERSION = "MaxBot (2023.12.24)"
CONST_APP_VERSION = "MaxBot (2023.12.25)"
CONST_MAXBOT_CONFIG_FILE = "settings.json"
CONST_MAXBOT_LAST_URL_FILE = "MAXBOT_LAST_URL.txt"
CONST_MAXBOT_INT28_FILE = "MAXBOT_INT28_IDLE.txt"
CONST_MAXBOT_ANSWER_ONLINE_FILE = "MAXBOT_ONLINE_ANSWER.txt"
CONST_MAXBOT_QUESTION_FILE = "MAXBOT_QUESTION.txt"
MAXBOT_EXTENSION_NAME = "Maxbot_1.0.0"
MAXBOT_EXTENSION_STATUS_JSON = "status.json"
CONST_HOMEPAGE_DEFAULT = "https://tixcraft.com"
URL_CHROME_DRIVER = 'https://chromedriver.chromium.org/'
@ -380,7 +382,7 @@ def get_favoriate_extension_path(webdriver_path, config_dict):
extension_list = []
if config_dict["advanced"]["adblock_plus_enable"]:
extension_list.append(os.path.join(webdriver_path,"Adblock_3.21.1.0.crx"))
extension_list.append(os.path.join(webdriver_path,"Maxbot_1.0.0.crx"))
extension_list.append(os.path.join(webdriver_path, MAXBOT_EXTENSION_NAME + ".crx"))
return extension_list
def get_chromedriver_path(webdriver_path):
@ -593,7 +595,7 @@ def get_uc_options(uc, config_dict, webdriver_path):
ext = ext.replace('.crx','')
if os.path.exists(ext):
# sync config.
if "Maxbot_" in ext:
if MAXBOT_EXTENSION_NAME in ext:
target_path = ext
target_path = os.path.join(target_path, "data")
target_path = os.path.join(target_path, "settings.json")
@ -12229,6 +12231,27 @@ def get_current_url(driver):
return url, is_quit_bot
def sync_status_to_extension(status):
Root_Dir = get_app_root()
webdriver_path = os.path.join(Root_Dir, "webdriver")
target_path = os.path.join(webdriver_path, MAXBOT_EXTENSION_NAME)
target_path = os.path.join(target_path, "data")
target_path = os.path.join(target_path, MAXBOT_EXTENSION_STATUS_JSON)
#print("save as to:", target_path)
status_json={}
status_json["status"]=status
#print("dump json to path:", target_path)
if not status:
with open(target_path, 'w') as outfile:
json.dump(status_json, outfile)
else:
if os.path.exists(target_path):
try:
os.unlink(target_path)
except Exception as exc:
print(exc)
pass
def main(args):
config_dict = get_config_dict(args)
@ -12315,6 +12338,7 @@ def main(args):
is_maxbot_paused = False
if os.path.exists(CONST_MAXBOT_INT28_FILE):
is_maxbot_paused = True
sync_status_to_extension(not is_maxbot_paused)
if len(url) > 0 :
if url != last_url:

View File

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

View File

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

View File

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

View File

@ -56,16 +56,7 @@ let heartbeatInterval;
async function runHeartbeat()
{
//console.log("runHeartbeat");
chrome.storage.local.get('status', function (items)
{
console.log(items);
if (items.status && items.status=='ON')
{
heartbeatconnect.start();
} else {
console.log('no status found');
}
});
}
async function startHeartbeat()

View File

@ -1 +1 @@
{"homepage": "https://kktix.com", "browser": "chrome", "language": "\u7e41\u9ad4\u4e2d\u6587", "ticket_number": 2, "ocr_captcha": {"enable": true, "beta": true, "force_submit": true, "image_source": "canvas"}, "webdriver_type": "undetected_chromedriver", "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true}, "tixcraft": {"date_auto_select": {"enable": true, "date_keyword": "", "mode": "random"}, "pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true}, "area_auto_select": {"enable": true, "mode": "random", "area_keyword": ""}, "keyword_exclude": "\"\u8f2a\u6905\",\"\u8eab\u969c\",\"\u8eab\u5fc3 \u969c\u7919\",\"Restricted View\",\"\u71c8\u67f1\u906e\u853d\",\"\u8996\u7dda\u4e0d\u5b8c\u6574\"", "advanced": {"play_captcha_sound": {"enable": true, "filename": "ding-dong.wav"}, "tixcraft_sid": "", "ibonqware": "", "facebook_account": "", "kktix_account": "", "fami_account": "", "cityline_account": "", "urbtix_account": "", "hkticketing_account": "", "kham_account": "", "ticket_account": "", "udn_account": "", "ticketplus_account": "", "facebook_password": "", "kktix_password": "", "fami_password": "", "urbtix_password": "", "cityline_password": "", "hkticketing_password": "", "kham_password": "", "ticket_password": "", "udn_password": "", "ticketplus_password": "", "adblock_plus_enable": false, "disable_adjacent_seat": false, "hide_some_image": true, "block_facebook_network": false, "headless": false, "verbose": true, "auto_guess_options": true, "user_guess_string": "", "online_dictionary_url": "", "auto_reload_page_interval": 1.0, "auto_reload_random_delay": false, "proxy_server_port": ""}}
{"homepage": "https://tixcraft.com", "browser": "chrome", "language": "\u7e41\u9ad4\u4e2d\u6587", "ticket_number": 2, "ocr_captcha": {"enable": true, "beta": true, "force_submit": true, "image_source": "canvas"}, "webdriver_type": "undetected_chromedriver", "kktix": {"auto_press_next_step_button": true, "auto_fill_ticket_number": true}, "tixcraft": {"date_auto_select": {"enable": true, "date_keyword": "", "mode": "random"}, "pass_date_is_sold_out": true, "auto_reload_coming_soon_page": true}, "area_auto_select": {"enable": true, "mode": "random", "area_keyword": ""}, "keyword_exclude": "\"\u8f2a\u6905\",\"\u8eab\u969c\",\"\u8eab\u5fc3 \u969c\u7919\",\"Restricted View\",\"\u71c8\u67f1\u906e\u853d\",\"\u8996\u7dda\u4e0d\u5b8c\u6574\"", "advanced": {"play_captcha_sound": {"enable": true, "filename": "ding-dong.wav"}, "tixcraft_sid": "", "ibonqware": "", "facebook_account": "", "kktix_account": "", "fami_account": "", "cityline_account": "", "urbtix_account": "", "hkticketing_account": "", "kham_account": "", "ticket_account": "", "udn_account": "", "ticketplus_account": "", "facebook_password": "", "kktix_password": "", "fami_password": "", "urbtix_password": "", "cityline_password": "", "hkticketing_password": "", "kham_password": "", "ticket_password": "", "udn_password": "", "ticketplus_password": "", "adblock_plus_enable": false, "disable_adjacent_seat": false, "hide_some_image": true, "block_facebook_network": false, "headless": false, "verbose": false, "auto_guess_options": true, "user_guess_string": "", "online_dictionary_url": "", "auto_reload_page_interval": 1.0, "auto_reload_random_delay": false, "proxy_server_port": ""}}

View File

@ -35,7 +35,7 @@
],
"web_accessible_resources": [
{
"resources": [ "data/settings.json" ],
"resources": [ "data/*.json" ],
"extension_ids": ["*"],
"matches": [ "*://*/*" ]
}
@ -143,8 +143,8 @@
"matches" : [
"https://kktix.com/events/*/registrations/new"
],
"run_at": "document_end",
"js" : [ "jquery.min.js", "js/kktix_registrations_new.js" ]
"run_at": "document_start",
"js" : [ "jquery.min.js", "js/kktix_registrations_reload.js" ]
}
],
"version": "1.0.0"

View File

@ -11,7 +11,10 @@ class HeartBeatConnector
//console.log("start heart beat connector");
//load_font.loadFont();
sync_status_from_parent();
// Query the active tab before injecting the content script
/*
chrome.tabs.query(
{
active: true,
@ -36,9 +39,51 @@ class HeartBeatConnector
}
}
});
*/
}
}
function sync_status_from_parent()
{
//console.log("sync_status_from_parent");
let data_url = chrome.runtime.getURL("data/status.json");
fetch(data_url)
.then(response => {
if (response.ok) {
return response.json()
} else if(response.status === 404) {
return Promise.reject('error 404')
} else {
return Promise.reject('some other error: ' + response.status)
}
})
.then((data) =>
{
console.log(data);
if(data) {
let nextState = 'ON';
if(!data.status) {
nextState = 'OFF';
}
//console.log(nextState);
chrome.action.setBadgeText({
text: nextState
});
chrome.storage.local.set(
{
status: nextState
}
);
}
})
.catch(error => {
//console.log('error is', error)
});
}
function ack() {
//console.log("act");
}