call the external processor

This commit is contained in:
buzz-lightsnack-2007 2024-04-14 23:24:04 +08:00
parent 08b10746b5
commit e21820576e

View file

@ -2,13 +2,10 @@
Be sensitive to changes and update the state. Be sensitive to changes and update the state.
*/ */
(async () => { let main = (async () => {
// Import modules. // Import modules.
let secretariat = await import(
chrome.runtime.getURL("scripts/secretariat.js")
);
let filters = new ((await import(chrome.runtime.getURL("scripts/filters.js"))).default); let filters = new ((await import(chrome.runtime.getURL("scripts/filters.js"))).default);
// let reader = await import(chrome.runtime.getURL("scripts/reader.js")); const processor = (await import(chrome.runtime.getURL("scripts/outside/processor.js"))).default;
class watchman { class watchman {
/* Check the current URL. /* Check the current URL.
@ -18,9 +15,7 @@ Be sensitive to changes and update the state.
*/ */
static async observe(URL = window.location.href) { static async observe(URL = window.location.href) {
// Create the variable to determine the corresponding key. // Create the variable to determine the corresponding key.
let activity = false; let activity = await filters.select(URL);
activity = await filters.select(URL);
return activity; return activity;
} }
@ -30,26 +25,32 @@ Be sensitive to changes and update the state.
@param {dictionary} filters the filter to work with @param {dictionary} filters the filter to work with
@return {boolean} the state @return {boolean} the state
*/ */
static act(filters) { static act(matches) {
console.log( console.log("ShopAI works here! Click on the button in the toolbar or website to start.");
"ShopAI works here! Click on the button in the toolbar or website to start.", // Show loading screen while the load is incomplete.
);
secretariat.write("state", true); // Set the icon to indicate that it's active.
// TODO
// Begin.
let PROC = new processor(matches);
window.addEventListener(`load`, (event) => {
// Remove the loading screen.
});
} }
/* Set the program to standby utnil next load. /* Set the program to standby utnil next load.
*/ */
static standby() { static standby() {
// Set the icon to indicate that it's not active. // Set the icon to indicate that it's not active.
secretariat.write("state", false);
} }
static async job() { static async job() {
/* The main action. */ /* The main action. */
(watchman.observe()).then((job_task) => {
if (job_task && Object.keys(job_task).length !== 0) { (watchman.observe()).then((RULES) => {
watchman.act(job_task); if (RULES && Object.keys(RULES).length !== 0) {
watchman.act(RULES);
} else { } else {
watchman.standby(); watchman.standby();
} }
@ -58,4 +59,7 @@ Be sensitive to changes and update the state.
} }
watchman.job(); watchman.job();
})(); });
main();