add extension to handle hkticketing

master
Your Name 2024-01-17 12:21:33 +08:00
parent 87156e5ca8
commit 5fcaa30be5
5 changed files with 108 additions and 1 deletions

View File

@ -162,6 +162,13 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
const tabId = sender.tab.id; const tabId = sender.tab.id;
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=="status") {
result_json={"status": answer};
const tabId = sender.tab.id;
chrome.tabs.sendMessage(tabId, result_json);
}
}); });

View File

@ -14,6 +14,11 @@ function begin()
auto_reload_page_interval = settings.advanced.auto_reload_page_interval; auto_reload_page_interval = settings.advanced.auto_reload_page_interval;
} }
// too short to cause error.
if(auto_reload_page_interval < 0.5) {
auto_reload_page_interval = 0.5;
}
if(status=='ON') { if(status=='ON') {
setInterval(() => { setInterval(() => {
retry(); retry();
@ -23,7 +28,7 @@ function begin()
function dom_ready() function dom_ready()
{ {
console.log("checking..."); //console.log("checking...");
if($("#settings").length>0) { if($("#settings").length>0) {
clearInterval(myInterval); clearInterval(myInterval);
begin(); begin();

View File

@ -0,0 +1,32 @@
const storage = chrome.storage.local;
var settings = null;
function hkticketing_msg_start(status)
{
if(settings) {
let settings_div="<div style='display:none' id='settings'>" + JSON.stringify(settings) + "</div>";
$("body").append(settings_div);
let status_div="<div style='display:none' id='status'>" + status + "</div>";
$("body").append(status_div);
console.log("dom append");
}
}
storage.get('settings', function (items)
{
if (items.settings)
{
settings = items.settings;
}
});
storage.get('status', function (items)
{
if (items.status && items.status=='ON')
{
hkticketing_msg_start(items.status);
} else {
console.log('no status found');
}
});

View File

@ -0,0 +1,41 @@
function begin()
{
const settings_div = document.querySelector('#settings');
const status_div = document.querySelector('#status');
let settings = JSON.parse(settings_div.innerHTML);
let status = status_div.innerHTML;
console.log("msg");
console.log(settings);
console.log(status);
let auto_reload_page_interval = 0.0;
if(settings) {
auto_reload_page_interval = settings.advanced.auto_reload_page_interval;
}
// too short to cause error.
if(auto_reload_page_interval < 0.8) {
auto_reload_page_interval = 0.8;
}
if(status=='ON') {
setInterval(() => {
busyFor = 0;
reload();
}, auto_reload_page_interval * 1000);
}
}
function dom_ready()
{
//console.log("checking...");
const settings_div = document.querySelector('#settings');
if(settings_div) {
clearInterval(myInterval);
begin();
}
}
myInterval = setInterval(() => {
dom_ready();
}, 100);

View File

@ -245,6 +245,28 @@
"js/ibon_ticket_next.js" "js/ibon_ticket_next.js"
] ]
}, },
{
"matches": [
"https://queue.hkticketing.com/hotshow.html",
"https://busy.hkticketing.com/"
],
"run_at": "document_end",
"js": [
"jquery.min.js",
"js/hkticketing_queue_background.js"
]
},
{
"matches": [
"https://queue.hkticketing.com/hotshow.html",
"https://busy.hkticketing.com/"
],
"run_at": "document_end",
"world": "MAIN",
"js": [
"js/hkticketing_queue_front.js"
]
},
{ {
"matches": [ "matches": [
"https://msg.cityline.com/*.html*" "https://msg.cityline.com/*.html*"