Skip to content

Commit 3e3d1db

Browse files
author
hoang.tran12
committed
.
1 parent 0754a38 commit 3e3d1db

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

content-scripts/document_start.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
function injectScriptFile(filePathOrUrl, isExternal = false) {
2-
var s = document.createElement("script");
3-
s.src = isExternal ? filePathOrUrl : chrome.runtime.getURL(filePathOrUrl);
4-
s.onload = function () {
5-
console.log("Useful-scripts injected " + s.src);
6-
this.remove();
7-
};
8-
s.onerror = function () {
9-
console.warn("ERROR: Useful-scripts inject script FAILED " + s.src);
10-
this.remove();
11-
};
12-
(document.head || document.documentElement).appendChild(s);
2+
try {
3+
var s = document.createElement("script");
4+
s.src = isExternal ? filePathOrUrl : chrome.runtime.getURL(filePathOrUrl);
5+
s.onload = function () {
6+
console.log("Useful-scripts injected " + s.src);
7+
this.remove();
8+
};
9+
s.onerror = function (e) {
10+
console.log("ERROR: Useful-scripts inject script FAILED " + s.src, e);
11+
this.remove();
12+
};
13+
(document.head || document.documentElement).appendChild(s);
14+
} catch (e) {
15+
console.log(
16+
"ERROR: Useful-scripts inject script FAILED " + filePathOrUrl,
17+
e
18+
);
19+
}
1320
}
1421

1522
injectScriptFile("/content-scripts/globals_debugger.js");

0 commit comments

Comments
 (0)