split the content script from watch
This commit is contained in:
parent
a226f12645
commit
3e683a7803
2 changed files with 63 additions and 56 deletions
14
scripts/external/content.js
vendored
Normal file
14
scripts/external/content.js
vendored
Normal 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();
|
||||
})
|
21
scripts/external/watch.js
vendored
21
scripts/external/watch.js
vendored
|
@ -2,14 +2,13 @@
|
|||
Be sensitive to changes and update the state.
|
||||
*/
|
||||
|
||||
let main = (async () => {
|
||||
// Import modules.
|
||||
let filters = new ((await import(chrome.runtime.getURL("scripts/filters.js"))).default);
|
||||
const processor = (await import(chrome.runtime.getURL("scripts/external/processor.js"))).default;
|
||||
const logging = (await import(chrome.runtime.getURL("scripts/logging.js"))).default;
|
||||
const texts = (await import(chrome.runtime.getURL("scripts/strings/read.js"))).default;
|
||||
import filters from "/scripts/filters.js";
|
||||
import processor from "/scripts/external/processor.js";
|
||||
import logging from "/scripts/logging.js";
|
||||
import texts from "/scripts/mapping/read.js";
|
||||
|
||||
class watchman {
|
||||
|
||||
export default class watchman {
|
||||
/* Check the current URL.
|
||||
|
||||
@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) {
|
||||
// Create the variable to determine the corresponding key.
|
||||
let activity = await filters.select(URL);
|
||||
let activity = await (new filters).select(URL);
|
||||
|
||||
return activity;
|
||||
}
|
||||
|
@ -61,9 +60,3 @@ let main = (async () => {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
watchman.job();
|
||||
});
|
||||
|
||||
|
||||
main();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue