It so happened that in the last few days, Firefox did not close normally twice. The first time he honestly gave up (crash) after a long period of intensive work, carrying on board more than 50 extensins, and the second time: he came to work today - and the computer was turned off. It turned out that electricity was cut down ...
For the first time, I noticed that the settings of one extension, which I was using at that time, were not saved. I had to re-configure. But when today I had to restore these settings a second time, I thought that this should not be so.
After searching a bit, I found that Firefox does save the settings to the prefs.js file
(lives at C: \ Documents and Settings \ User \ Application Data \ Mozilla \ Firefox \ Profiles \ sDgUfwhg.default \ prefs.js)
only with a regular closure (and even with some movements that surfaced during the investigation).
')
But the browser in our time almost never closes ... So there must be a solution;)
There is a typical situation:
So I just made some amendments to the extensin settings (for example, added the site to the white list of BetterCache, or Stop Autoplay). I know for sure that these settings are stored in prefs.js, that is, they will actually be saved to the screw when the browser is closed. And now, in order not to lose the work done, now there is a desire to close and open the browser (or restart), but I really don’t want to, as many tabs are open, and in general the browser should not close. It turns out that if you do nothing and continue to work, then such data will most likely be lost.
A similar problem exists with Windows applications that store data in the registry: very rarely, but it happened that I received a BSOD and noticed after loading that the settings of some programs “forgot” all my recent changes. That is, changes in the registry is also not immediately saved on the screw.
In this situation with Firefox, I started looking for a solution to save the settings, or rather, how to make flush settings in the prefs.js file, without closing the browser.
I thought that there might already be some kind of extension, but the search on addons.mozilla.org did not yield any results (I was once again convinced that they had no search).
Then I started to google on the topic “prefs.js” flush and found 2 explanatory pages:
www.softwarepunk.com/blog/firefox-preferences-flush.html
fixunix.com/mozilla/408327-savepreffile-doesnt-really-work.html
So in half an hour I already had the code:
Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).savePrefFile(null)
But running it in the Firebug console, I got:
Error: Permission denied for <...> to get property XPCComponents.classes
For any page of any site.
Then I thought that you need to try not on sites, but on the internal Firefox pages. I try on about: config - a characteristic delay Ń– no error message. I look at prefs.js - updated.
Checked in the text search for the presence of the domains I whitelisted are present, which means the preservation of recent changes is exactly happening.
Now the next task: how to make saving convenient?
The first thought is a bookmarklet. I create a bookmark, I register it in the Location:
javascript:Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).savePrefFile(null)
I try with the open page about: config - it works, on all others - Permission denied.
That's what I'm stuck with.
How to make the button work no matter which site is open? (open about: config with the script, run the code there and close it? I think it will not work for the same reason that we get Permission denied - a security violation).
How to make a normal button, or so that it doesn’t need a button at all, but just so that the save code works periodically? (Write an extension? I have no experience, if there is anyone more experienced - help).
UPD. A good man was found, see the first comment.
So far, I manually open about: config and press the button of the bookmarklet for which I made an icon

(
download ).
I put the icon using the extenic
Favicon Picker 3 .
Noticed
When you click on such a bookmarklet, saving occurs only if something has really changed in the settings. Otherwise, nothing happens, prefs.js does not move, and there is no noticeable delay when the button is pressed. It is very good to periodically save in the background, if this is done somehow.
Passing thoughts
In a good way, this extensions should flush when closing their settings window, not the user. Similarly, Firefox could do this periodically, and not only at closing and, as it turned out about the research process, with changes in the browser settings (the Options window or the about: config tab). Each time to change something in the settings, or in the table about: config, changing back and forth an arbitrary boolean parameter is also an option, but still not the same ...
I hope that together the community can find / come up with a better solution than what I got.