Skip to content
This repository has been archived by the owner on Nov 7, 2022. It is now read-only.

Commit

Permalink
feat: load sidekick as module into sandbox
Browse files Browse the repository at this point in the history
  • Loading branch information
rofe committed Oct 16, 2021
1 parent 021f56b commit 5397039
Show file tree
Hide file tree
Showing 5 changed files with 1,629 additions and 59 deletions.
15 changes: 4 additions & 11 deletions src/extension/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,8 @@ function checkTab(id) {
// enable extension for this tab
browser.pageAction.show(id);
browser.tabs.executeScript(id, {
runAt: 'document_start',
file: './lib/browser-polyfill.min.js',
})
.then(() => browser.tabs.executeScript(id, {
file: './content.js',
}))
.catch((e) => console.error('failed to inject scripts', e));
file: './content.js',
});
} else {
// disable extension for this tab
browser.pageAction.hide(id);
Expand All @@ -66,7 +61,7 @@ function toggle(id) {
/**
* Adds the listeners for the extension.
*/
function addListeners() {
(() => {
// toggle the sidekick when the browser action is clicked
browser.pageAction.onClicked.addListener(({ id }) => {
toggle(id);
Expand Down Expand Up @@ -125,6 +120,4 @@ function addListeners() {
}
});
});
}

addListeners();
})();
7 changes: 3 additions & 4 deletions src/extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@
"page": "background.html"
},
"web_accessible_resources": [
"app.css",
"app.js",
"helix.svg",
"configpicker.js",
"lib/browser-polyfill.min.js",
"module.js",
"sidekick.js",
"utils.js"
],
"page_action": {
"page_action": {
"default_title": "__MSG_title__",
"default_icon": {
"16": "icons/helix_logo_16.png",
Expand Down
Loading

0 comments on commit 5397039

Please sign in to comment.