split the content script from watch

This commit is contained in:
buzz-lightsnack-2007 2024-04-26 21:33:28 +08:00
parent a226f12645
commit 3e683a7803
2 changed files with 63 additions and 56 deletions

14
scripts/external/content.js vendored Normal file
View file

@ -0,0 +1,14 @@
/*
content.js
The content script
*/
// Import the necessary modules.
(async () => {
// Import the watchman module.
let watchman = await import(chrome.runtime.getURL("scripts/external/watch.js"));
// Begin the job.
watchman.job();
})

View file

@ -2,14 +2,13 @@
Be sensitive to changes and update the state. Be sensitive to changes and update the state.
*/ */
let main = (async () => { import filters from "/scripts/filters.js";
// Import modules. import processor from "/scripts/external/processor.js";
let filters = new ((await import(chrome.runtime.getURL("scripts/filters.js"))).default); import logging from "/scripts/logging.js";
const processor = (await import(chrome.runtime.getURL("scripts/external/processor.js"))).default; import texts from "/scripts/mapping/read.js";
const logging = (await import(chrome.runtime.getURL("scripts/logging.js"))).default;
const texts = (await import(chrome.runtime.getURL("scripts/strings/read.js"))).default;
class watchman {
export default class watchman {
/* Check the current URL. /* Check the current URL.
@param {string} URL the page URL; default value is the current webpage @param {string} URL the page URL; default value is the current webpage
@ -17,7 +16,7 @@ let main = (async () => {
*/ */
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 = await filters.select(URL); let activity = await (new filters).select(URL);
return activity; return activity;
} }
@ -60,10 +59,4 @@ let main = (async () => {
} }
}); });
} }
} }
watchman.job();
});
main();