34 lines
914 B
JavaScript
34 lines
914 B
JavaScript
console.log("background.js starts now");
|
|
|
|
function handlePageactionClick(tab, onClickData) {
|
|
console.log("background.js: executing content script");
|
|
let executing = browser.scripting.executeScript({
|
|
files: [ "/contentscript.js" ],
|
|
target: {
|
|
tabId: tab.id,
|
|
allFrames: false
|
|
}
|
|
});
|
|
executing.then(onExecuted, onExecutionError);
|
|
}
|
|
|
|
function onExecuted(result) {
|
|
console.log(`background.js: content script execution successful with result: ${JSON.stringify(result)}`);
|
|
}
|
|
|
|
|
|
function onExecutionError(error) {
|
|
console.error(`background.js: The following error occured while executing a content script: ${error}`);
|
|
}
|
|
|
|
|
|
let gettingAllPermissions = browser.permissions.getAll();
|
|
gettingAllPermissions.then((allPermissions) => {
|
|
console.log(JSON.stringify(allPermissions))
|
|
});
|
|
|
|
|
|
|
|
// add listener for the extension button
|
|
browser.pageAction.onClicked.addListener(handlePageactionClick);
|