0

I have a restartless firefox extension in which I have an array which is used for some decision making. The elements of this array can change overtime.

Currently I have my bootstrap.js file which calls various functions present in another .js files. And within one of these functions is this array.

I am trying to figure out how can I restructure my code in such a way that I can update this array (not entire extension) after installation.

What I have thought of is; to pull this array out into a separate .js file and plan to swap this when I make the array 'update' after installation.

However, I still don't understand how to do it. The way I understand is, I bundle my add-on as an .xpi it gets installed and then is it possible to do a partial upgrade?

I don't want to push another .xpi for this. And I assume that will also make the user aware that the extension has updated. Since, the array updates can be frequent this can look really weird for the user updates happening every week or so.

Can I do this over an API that will fetch the updated array and swap it in the code ( Do .push to existing array ) ? Basically, I want this to be invisible to the user and lightweight as well.

How can I do it in a better/correct way? If I am asking for something not presently possible let me know.

Suvarna Pattayil
  • 5,136
  • 5
  • 32
  • 59
  • Once the extension is installed, how could that array be updated? Is the update result of user action within extension UI or is it pulled from a remote url? – Kashif May 09 '16 at 02:19
  • @Kashif No it is not result of direct user action. My extension just sits in the browser and based on what the user types refers the array for certain decision making.This array can be updated irrelevant of user actions. Even if I have to pull from remote URL (I assume I'll have to keep some periodic check for this then ?) is it possible to update the array after installation? I can call the URL which will provide the new array elements or ones to be removed. Can I do that after an installation and how to do it is something I wanted to know. – Suvarna Pattayil May 09 '16 at 05:44
  • Can you make a REST API request to a server that returns the json? And it then saves that json to disk, in case of no internet access in future checks, and for offline use. – Noitidart May 09 '16 at 19:16

1 Answers1

1

Anything that you include in xpi, will be updated when there is a new install of that xpi.

As you mentioned that the updates would be frequent, you could possibly fetch the array from a remote end-point. This could be a json file or rest call whatever you think is more suitable. To improve performace, you can fetch array from remote end-point, store it in user profile directory and only fetch it again based on some expiry period (e.g. every week or fortnight).

Be aware in that case, if your extension needs to be distributed through AMO, the review process may require some additional steps e.g. including a privacy policy, barring use of eval on array contents.

Kashif
  • 1,238
  • 10
  • 15