From 1bcea261fb37b4845458d89166c16e1010ced203 Mon Sep 17 00:00:00 2001 From: buzzcode2007 <73412182+buzz_lightsnack_2007@users.noreply.github.com> Date: Tue, 2 Apr 2024 15:01:39 +0800 Subject: [PATCH] update to the fact that filters is now a default class --- scripts/watchman.js | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/scripts/watchman.js b/scripts/watchman.js index 84b1e27..84c37b9 100644 --- a/scripts/watchman.js +++ b/scripts/watchman.js @@ -7,9 +7,7 @@ Be sensitive to changes and update the state. let secretariat = await import( chrome.runtime.getURL("scripts/secretariat.js") ); - let filters = (await import(chrome.runtime.getURL("scripts/filters.js")))[ - `filters` - ]; + let filters = (await import(chrome.runtime.getURL("scripts/filters.js"))).default; // let reader = await import(chrome.runtime.getURL("scripts/reader.js")); class watchman { @@ -18,13 +16,11 @@ Be sensitive to changes and update the state. @param {string} URL the page URL; default value is the current webpage @return {dictionary} the filter to follow */ - static observe(URL = window.location.href) { + static async observe(URL = window.location.href) { // Create the variable to determine the corresponding key. let activity = false; - // let filters = secretariat.specifics(`filters`, URL); - - // Check if the filters exist. - activity = filters; + + activity = await filters.select(URL); return activity; } @@ -49,14 +45,15 @@ Be sensitive to changes and update the state. ); } - static job() { + static async job() { /* The main action. */ - let job_task = watchman.observe(); - if (job_task) { - watchman.act(job_task); - } else { - watchman.standby(); - } + (watchman.observe()).then((job_task) => { + if (job_task && Object.keys(job_task).length !== 0) { + watchman.act(job_task); + } else { + watchman.standby(); + } + }); } }