mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-17 23:08:33 +02:00
Add an error handler for content script injection
This commit is contained in:
@@ -58,10 +58,15 @@ document.addEventListener("click", (e) => {
|
||||
});
|
||||
}
|
||||
|
||||
function reportError(error) {
|
||||
console.error(`Could not inject content script: ${error}`);
|
||||
}
|
||||
|
||||
if (e.target.classList.contains("beast")) {
|
||||
injectTestScript()
|
||||
.then(injectBeastify)
|
||||
.then(messageBeastify);
|
||||
.then(messageBeastify)
|
||||
.catch(reportError);
|
||||
}
|
||||
else if (e.target.classList.contains("clear")) {
|
||||
browser.tabs.reload();
|
||||
|
||||
Reference in New Issue
Block a user