Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using firefox extension storage

I'm able to run this extension somehow:

https://github.com/mdn/webextensions-examples/tree/master/beastify

On clicking the Browser Icon popup/choose_beast.js is invoked.

Can somebody tell me why this code(placed in the top of popup/choose_beast.js) is generating exception:

try{
var ss = require("sdk/simple-storage");
ss.storage.myArray = [1, 1, 2, 3, 5, 8, 13];
}catch(e){
    alert('exception');
    console.log(e);
}

Here is the relevant entry in the manifest.json:

 "browser_action": {
    "default_icon": "icons/beasts-32.png",
    "default_title": "Beastify",
    "default_popup": "popup/choose_beast.html"
}

What is the way I can store the data in this popup html so that I can retrieve anytime in the content script?

Also under which context is this page choose_beast.html running? Background, page script or content script?

like image 678
user5858 Avatar asked Jul 10 '26 15:07

user5858


1 Answers

A web-extension should be using storage API for this purpose.

Here is an example usage.

like image 64
Kashif Avatar answered Jul 16 '26 01:07

Kashif



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!