Skip to content

Commit 20c884d

Browse files
author
hoang.tran12
committed
fix run scripts
1 parent c6a055e commit 20c884d

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

scripts/content-scripts/run_scripts.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,24 @@ function getCurrentScriptSrc() {
4141
function runScripts(scriptIds, event, path) {
4242
for (let id of scriptIds.filter((_) => _)) {
4343
let scriptPath = `${path}/${id}.js`;
44-
import(scriptPath).then(({ default: script }) => {
45-
try {
46-
if (
47-
event in script &&
48-
typeof script[event] === "function" &&
49-
checkWillRun(script)
50-
) {
51-
console.log("> Useful-script: Run script " + id + " " + event);
52-
script[event]();
44+
import(scriptPath)
45+
.then(({ default: script }) => {
46+
try {
47+
if (
48+
event in script &&
49+
typeof script[event] === "function" &&
50+
checkWillRun(script)
51+
) {
52+
console.log("> Useful-script: Run script " + id + " " + event);
53+
script[event]();
54+
}
55+
} catch (e) {
56+
console.log("ERROR run script " + id + " " + event, e);
5357
}
54-
} catch (e) {
55-
console.log("ERROR run script " + id + " " + event, e);
56-
}
57-
});
58+
})
59+
.catch((e) => {
60+
console.log("ERROR import script ", e);
61+
});
5862
}
5963
}
6064

0 commit comments

Comments
 (0)