Reputation: 9560
I am working on a FireFox add-on which uses the WebExtensions API.
We want to open a new tab when the user installs the extension. There is an event called management.onInstalled()
, but FireFox does not support this.
Another event runtime.onInstalled
is working for FireFox newer than version 52.0. Is there a reliable way to achieve this feature for all FireFox versions? Thanks.
Upvotes: 1
Views: 121
Reputation: 15548
Well, the way I have done it in the past is to use the storage. So every time the addon is started you check if there is an entry called 'hasBeenRun' in the local storage. If not, then you can open your tab and set the 'hasBeenRun' to true. Otherwise you simply ignore it.
browser.storage.local.get('hasBeenRun').then(data => {
if (!data.hasBeenRun) {
browser.storage.local.set({'hasBeenRun':true}).then(()=>{
// do your tab opening magic
}
});
Upvotes: 2