Programmatically create Firefox profiles

Question

Is there an easy programmatic way to create new Firefox profiles?

nsIToolkitProfileService looks like this might do the trick, but docs say:

Starting with Gecko 18 (Firefox 18.0 / Thunderbird 18.0 / SeaMonkey 2.15 / Firefox OS 1.0.1), you should no longer use this service or nsIToolkitProfile

Why

I am interested in doing this because I think it can be used to easily run independent Firefox executables (for example, for each application there can be a completely separate icon in the taskbar) without the need for non-existing Prism / Chromeless / WebRunner projects.

My approach would be to create a Firefox add-in that would allow the user to specify the URL of the web application and then automatically create a profile for them with names such as "Executable 1", "Executable 2", etc. for the application, as well as a batch file that will invoke the “-no-remote” command line argument against this profile and the application (since -no-remote seems to require creating a profile to create a new instance (the “-new-instance” argument , which I have seen is mentioned in an error, does not seem to work for me).

+4
source share
2 answers

I assume that people either wanted to avoid the main stream I / O. Or there were negotiations to remove the profile manager from the application in order to speed up the launch and simplify the startup code as a whole, so this could be the reason. It looks like the victorporof wiki user did this editing, so you probably should tell him for an explanation (IIRC, he got the address @ mozilla.com, which you could easily do Google;)

In any case, the new profile is not much more than an empty directory. The application actually copies / creates the missing files immediately after its launch. Thus, your add-on can simply:

  • Create an empty directory in the right place.
  • Open instance: -no-remote -profile $dir
  • Add icons or something else.
  • Do this.
  • It’s not necessary to mess with profile.ini so that the new profile gets into the regular profile manager.

I regularly do such things from the command line, for example.

 mkdir -p central.profile && path/to/filefox -no-remote -profile $PWD/central.profile 

Or just keep using nsITOolkitProfileService until it is removed. (This is what I will probably do). FWIW, there is still new code still using it as a (remote) debugger.

Also, it might be worth taking a look at the standalone profile manager that they encoded.

+4
source

Therefore, according to Neil from ask.mo, he said that the message that they did not use this service was automatically delivered there when they made OS.File. He added that the message is false on this page. The service is available, but OS.File is the preferred way. So I created some functions to do this with OS.File

TOPIC LINK: ask.mo: OS.File instead of nsiToolkitProfileService?

Here it is: https://gist.github.com/yajd/9791029

It remains to be done much more finely tuned, which I did in my Profilist addon, I will release it soon, and then publish it here.

+1
source

Source: https://habr.com/ru/post/1501411/


All Articles