@erosman I have created test add-on that implements your approach. Unfortunately, I see Error: permissions.request may only be called from a user input handler
in add-on debug console when click on “click me to request permissions” button
Code:
background.js:
browser.runtime.onMessage.addListener(() => {
browser.permissions.request({ permissions: ['clipboardRead']})
.then(granted => console.log(granted));
});
content.js:
var btn = document.createElement('button');
btn.innerHTML = 'click me to request permissions';
btn.addEventListener('click', () => {
browser.runtime.sendMessage({});
});
document.body.appendChild(btn);
manifest.json:
{
"background":{
"scripts":[
"background.js"
]
},
"name":"Test Permissions in Firefox",
"manifest_version":2,
"optional_permissions": [ "clipboardRead" ],
"permissions":[ "<all_urls>" ],
"content_scripts": [
{
"matches": ["*://*.example.com/*"],
"js": ["content.js"]
}
],
"version":"0.0.1"
}