Skip to content

Commit

Permalink
Additional error detection.
Browse files Browse the repository at this point in the history
  • Loading branch information
MIvanchev committed Mar 22, 2022
1 parent 9e34582 commit fa0f9f2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ async function notify(message) {
var enabled = message.enabled;

if (reg) {
await reg.unregister();
reg = null;
try {
await reg.unregister();
reg = null;
} catch (err) {
console.log(`Error while unregistering script: ${err}`)
}
}

if (enabled) {
if (!reg && enabled) {
var options = {
"js": [{
"file": "jquery-3.6.0.min.js"
Expand All @@ -38,7 +42,11 @@ async function notify(message) {
"runAt": "document_start"
};

reg = await browser.userScripts.register(options);
try {
reg = await browser.userScripts.register(options);
} catch (err) {
console.log(`Error while registering script: ${err}`)
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ function restoreOptions() {
});
}
document.addEventListener("DOMContentLoaded", restoreOptions);
document.querySelector("form").addEventListener("submit", saveOptions);
document.querySelector("form").addEventListener("submit", saveOptions);

0 comments on commit fa0f9f2

Please sign in to comment.