搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

Learn More

Could Firefox ask for main password at launching, not tenth seconds after ?

more options

Hello, I am French but I try to write in English... When I launch Firefox, I know it will ask for my main password. This is what I need, me for I activated "Sync" (to synchronize my profile on PC and Android). My problem is not "how to prevent Firefox to ask for my main password" (many people ask for that on the net). It is "how to prevent Firefox to wait about 30 seconds before asking for my main password".

I did read only one thread about the trouble I encounter each time I launch Firefox but I gess many people experiment the same thing. https://support.mozilla.org/en-US/questions/1312988 (you can see the source is a very good one :-) ) I entirely agree with the author, who wrote :

"The delay in the master password prompt is up to 20 seconds and is so annoying, it just gets in the way when you are trying to work."

So, you launch Firefox, you look for one of your bookmarks to click on it but then, Firefox stops your action and a window asks your password. Worse : you are typing words in the adress bar and after some seconds you discover that you were typing the last words in the password pop-up window. Awfull ! You can then 1/ grumble and type your password 2/ grumble an press the Escape key

I use sometimes Seamonkey, that asks for the main password within the second you click its shortcut on Windows desktop. An excellent solution ! But after that, I notice that Seamonkey does not have a Sync function (and Firefox asks for the main password 20 or 30 seconds after opening only if Sync is activated).

To sum up, it would be great if Mozilla / Sync could remove the delay before asking for the main password, even if it has to ask for it right after clicking on the desktop shortcut. Thanks for any advice, Michel

Hello, I am French but I try to write in English... When I launch Firefox, I know it will ask for my main password. This is what I need, me for I activated "Sync" (to synchronize my profile on PC and Android). My problem is not "how to prevent Firefox to ask for my main password" (many people ask for that on the net). It is "how to prevent Firefox to wait about 30 seconds before asking for my main password". I did read only one thread about the trouble I encounter each time I launch Firefox but I gess many people experiment the same thing. https://support.mozilla.org/en-US/questions/1312988 (you can see the source is a very good one :-) ) I entirely agree with the author, who wrote : "The delay in the master password prompt is up to 20 seconds and is so annoying, it just gets in the way when you are trying to work." So, you launch Firefox, you look for one of your bookmarks to click on it but then, Firefox stops your action and a window asks your password. Worse : you are typing words in the adress bar and after some seconds you discover that you were typing the last words in the password pop-up window. Awfull ! You can then 1/ grumble and type your password 2/ grumble an press the Escape key I use sometimes Seamonkey, that asks for the main password within the second you click its shortcut on Windows desktop. An excellent solution ! But after that, I notice that Seamonkey does not have a Sync function (and Firefox asks for the main password 20 or 30 seconds after opening only if Sync is activated). To sum up, it would be great if Mozilla / Sync could remove the delay before asking for the main password, even if it has to ask for it right after clicking on the desktop shortcut. Thanks for any advice, Michel

被選擇的解決方法

This probably means that the signon.startup.prompt pref doesn't exists, so double check that on about:config and in prefs.js. I would have expected that this was caught by the try{} catch(){} block, but apparently not. The below posted code check the type of the pref and should prevent this error.

// autoconfig.cfg needs to start with a comment line
let {classes:Cc, interfaces:Ci, utils:Cu} = Components; // autoconfig.js => pref("general.config.sandbox_enabled", false);
const {Services} = Cu.import('resource://gre/modules/Services.jsm');

/* Ask for Primary Password at startup - signon.startup.prompt */
let initLogins = true;

if (initLogins) {
 try {
  let {classes:Cc, interfaces:Ci, manager:Cm, utils:Cu} = Components;
  const {Services} = Cu.import('resource://gre/modules/Services.jsm');

  let signon_startup_prompt = "signon.startup.prompt";
  if (Services.prefs.getPrefType(signon_startup_prompt) && Services.prefs.getBoolPref(signon_startup_prompt)){
   Services.obs.addObserver(function (aSubject, aTopic, aData) {
    var chromeWindow = aSubject;
    chromeWindow.setTimeout(function () {
     try {
      let logins =  Services.logins.getAllLogins({});
     } catch (e) { Cu.reportError(e); }
    }, 10);
   }, "browser-delayed-startup-finished", false);
  }
 } catch (e) { Cu.reportError(e); }
} /* [initLogins] */

從原來的回覆中察看解決方案 👍 1

所有回覆 (13)

more options

In the Thread you gave and I found, too, (post at page bottom) DID YOU do this ..... A simple workaround that forces the Firefox Primary Password to be immediately required on startup is to -- make your home page (in Options > Home > New Windows and Tabs) --- use a login page for a site for which you have a password saved in Firefox. The option to "Ask to save logins and passwords for websites" (Options > Privacy & Security > Logins and Passwords) must be on.

The page doesn't even have to be at a site for which you have an account. It can be a dummy login page. All that is required is for Firefox to think you have a password for that page. https://support.mozilla.org/sv/questions/1312988

由 CraigS26 於 修改

more options

As you know, using Sync is a possible reason to ask for the Primary Password at startup. This is because the credentials to login to the Sync account are stored in the Password Manager and you need to enter the Primary Password to unlock the passwords and connect/login to the Sync account.

Sync isn't initiated immediately, but is done at a later time for performance reasons (i.e. let the startup as quick as possible). When there is a need to sync data to the Sync server then Sync is initiated and you need to enter the PP if you use one. To speed up for entering the PP you would have to take an action that triggers entering the PP like opening the about:logins page, so you can possibly open about:logins as a pinned tab.

more options

CraigS26 said

In the Thread you gave and I found, too, (post at page bottom) DID YOU do this ..... A simple workaround that forces the Firefox Primary Password to be immediately required on startup is to -- make your home page (in Options > Home > New Windows and Tabs) --- use a login page for a site for which you have a password saved in Firefox. The option to "Ask to save logins and passwords for websites" (Options > Privacy & Security > Logins and Passwords) must be on. The page doesn't even have to be at a site for which you have an account. It can be a dummy login page. All that is required is for Firefox to think you have a password for that page. https://support.mozilla.org/sv/questions/1312988

Yes, I tried that and it worked but the other solution (a dummy page) would be better (if it shows a blank page or anything I could write on it, as "This page is only needed to ask for my main password"). The trouble is that I can't see how to build such a dummy page...

more options

cor-el said

As you know, using Sync is a possible reason to ask for the Primary Password at startup. This is because the credentials to login to the Sync account are stored in the Password Manager and you need to enter the Primary Password to unlock the passwords and connect/login to the Sync account. Sync isn't initiated immediately, but is done at a later time for performance reasons (i.e. let the startup as quick as possible). When there is a need to sync data to the Sync server then Sync is initiated and you need to enter the PP if you use one. To speed up for entering the PP you would have to take an action that triggers entering the PP like opening the about:logins page, so you can possibly open about:logins as a pinned tab.

Thanks for these explanations about Sync. Creating a dummy page would suit me better but I don't know how do I create it. And how do I assign a password to such a page ? I guess it could be a local page on my PC.

more options

You don't need to create a 'dummy page.' Just open a login page for any website. What you could do is use a website where you don't have an account.

more options

I've looked at code for autoconfig.cfg to ask for the Primary Password at startup and have come up with the code posted further down. It is controlled via a Boolean (true/false pref I named signon.startup.prompt that you can set for a specific profile via the about:config page.


You can use the autoconfig.cfg file in the Firefox installation folder to initialize (set/lock) preferences and run privileged JavaScript code (requires to disable the sandbox).

To use Autoconfig, place two files into the Firefox installation directory.

  • on Windows and Linux, they go into the same directory where Firefox is installed
  • on macOS, they go into the Contents/Resources directory of the Firefox.app

The autoconfig.js file that specifies to use autoconfig.cfg is placed into the "defaults\pref" directory where the channel-prefs.js file is located.

// autoconfig.js starts with a comment line
pref("general.config.filename", "autoconfig.cfg");
pref("general.config.obscure_value", 0);
pref("general.config.sandbox_enabled", false); // required with privileged JavaScript

The autoconfig.cfg file is placed at the top level of the Firefox directory.

  • autoconfig.cfg and autoconfig.js need to start with a comment line (//)
  • autoconfig.js needs to use Unix line endings (LF instead of CR/LF)

See also:


// autoconfig.cfg needs to start with a comment line
let {classes:Cc, interfaces:Ci, utils:Cu} = Components; // autoconfig.js => pref("general.config.sandbox_enabled", false);
const {Services} = Cu.import('resource://gre/modules/Services.jsm');

/* Ask for Primary Password at startup - signon.startup.prompt */
let initLogins = true;

if (initLogins) {
 try {
  let {classes:Cc, interfaces:Ci, manager:Cm, utils:Cu} = Components;
  let Services = globalThis.Services || ChromeUtils.import("resource://gre/modules/Services.jsm").Services;
  let signon_startup_prompt = "signon.startup.prompt";
  if (Services.prefs.getPrefType(signon_startup_prompt) && Services.prefs.getBoolPref(signon_startup_prompt)){
   Services.obs.addObserver(function (aSubject, aTopic, aData) {
    var chromeWindow = aSubject;
    chromeWindow.setTimeout(function () {
     try {
      let logins =  Services.logins.getAllLogins({});
     } catch (e) { Cu.reportError(e); }
    }, 10);
   }, "browser-delayed-startup-finished", false);
  }
 } catch (e) { Cu.reportError(e); }
} /* [initLogins] */

由 cor-el 於 修改

more options

autoconfig.js data URI you can paste in the location bar to initiate a download, save as autoconfig.js

data:application/octet-stream;base64,Ly8KcHJlZigiZ2VuZXJhbC5jb25maWcuZmlsZW5hbWUiLCAiYXV0b2NvbmZpZy5jZmciKTsKcHJlZigiZ2VuZXJhbC5jb25maWcub2JzY3VyZV92YWx1ZSIsIDApOwpwcmVmKCJnZW5lcmFsLmNvbmZpZy5zYW5kYm94X2VuYWJsZWQiLCBmYWxzZSk7

If you want to inspect this file in a tab.

data:text/plain;base64,Ly8KcHJlZigiZ2VuZXJhbC5jb25maWcuZmlsZW5hbWUiLCAiYXV0b2NvbmZpZy5jZmciKTsKcHJlZigiZ2VuZXJhbC5jb25maWcub2JzY3VyZV92YWx1ZSIsIDApOwpwcmVmKCJnZW5lcmFsLmNvbmZpZy5zYW5kYm94X2VuYWJsZWQiLCBmYWxzZSk7

more options

FredMcD said

(...) What you could do is use a website where you don't have an account.

This is a very smart solution ! In this case, I would have to compare a few sites and take the one that loads the fastest.

more options

cor-el said

I've looked at code for autoconfig.cfg to ask for the Primary Password at startup and have come up with the code posted further down. It is controlled via a Boolean (true/false pref I named signon.startup.prompt that you can set for a specific profile via the about:config page. (...)

Thanks a lot for your answer ! I don't know anything about programming but I sometimes manipulate system files or others with Notepad++ (in which I chose the unix line endings before creating the two files you indicate). So, I created - the autoconfig.cfg file, in C:\Program Files\Mozilla Firefox - the file autoconfig.js in C:\Program Files\Mozilla Firefox\defaults\pref Of course, I copied / pasted the content you indicate.

Under about:config, I find the line signon.startup.prompt X Boolean Number String (my PC speaks only French...) For the moment, when I launch Firefox, it asks me for the password after about 20 seconds, as before, but maybe I made a mistake somewhere!

Translated with www.DeepL.com/Translator (free version)

more options

Does it work if you use the autoconfig.js file I posted above as the data URI as there could be a problem with your file ? Do you see general.config.sandbox_enabled = false on the about:config page ? Are there errors reported in the Browser Console about the autoconfig file?

You can add this line below the "const {Services}" line and check the Web Console to see if the autoconfig.cfg is actually processed at all.

  • Cu.reportError("TESTING autoconfig.cfg");

You can possibly add a few more such Cu.reportError(); lines to check the progress.


If I use this code then I see the PP prompt instantly when the Firefox window opens.

more options

cor-el said

Does it work if you use the autoconfig.js file I posted above as the data URI as there could be a problem with your file ? (...)

I tried the autoconfig.js file you posted instead of the first one.

I added the line Cu.reportError("TESTING autoconfig.cfg"); in autoconfig.cfg and the Firefox console shows that: ____________________________________________ TESTING autoconfig.cfg autoconfig.cfg:3

   <anonyme> autoconfig.cfg:3

___________________________________________ [Exception... "Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIPrefBranch.getBoolPref]" nsresult: "0x8000ffff (NS_ERROR_UNEXPECTED)" location: "JS frame :: autoconfig.cfg :: <TOP_LEVEL> :: line 10" data: no] autoconfig.cfg:10:22

   <anonyme> autoconfig.cfg:10

_________________________

I must add that it is the first time I open Firefox's console, and I understand very few things in it :-) . Indeed, I enjoy reading your messages and trying your solutions. But I would not want you to waste to much of your time ! Michel

more options

選擇的解決方法

This probably means that the signon.startup.prompt pref doesn't exists, so double check that on about:config and in prefs.js. I would have expected that this was caught by the try{} catch(){} block, but apparently not. The below posted code check the type of the pref and should prevent this error.

// autoconfig.cfg needs to start with a comment line
let {classes:Cc, interfaces:Ci, utils:Cu} = Components; // autoconfig.js => pref("general.config.sandbox_enabled", false);
const {Services} = Cu.import('resource://gre/modules/Services.jsm');

/* Ask for Primary Password at startup - signon.startup.prompt */
let initLogins = true;

if (initLogins) {
 try {
  let {classes:Cc, interfaces:Ci, manager:Cm, utils:Cu} = Components;
  const {Services} = Cu.import('resource://gre/modules/Services.jsm');

  let signon_startup_prompt = "signon.startup.prompt";
  if (Services.prefs.getPrefType(signon_startup_prompt) && Services.prefs.getBoolPref(signon_startup_prompt)){
   Services.obs.addObserver(function (aSubject, aTopic, aData) {
    var chromeWindow = aSubject;
    chromeWindow.setTimeout(function () {
     try {
      let logins =  Services.logins.getAllLogins({});
     } catch (e) { Cu.reportError(e); }
    }, 10);
   }, "browser-delayed-startup-finished", false);
  }
 } catch (e) { Cu.reportError(e); }
} /* [initLogins] */

由 cor-el 於 修改

more options

cor-el said

This probably means that the signon.startup.prompt pref doesn't exists, so double check that on about:config and in prefs.js. (...)

All is working fine now, as I checked about:config and prefs.js. the command signon.startup.prompt did not appear in prefs.js, and in about:config, it showed only signon.startup.prompt X Boolean Number String but the choice true / false was not there. I thought I had double-clicked on it but apparently no.

Sorry for that, all should have worked since your answer on the 4/27/22 at 12:30 pm. I hope many people will read your answer. I am sure thousands of Firefox users have noticed this problem with this master password pop-up that blocks what they have started to do on their PC.