set autofillForm pref to true only for several websites - Mozilla

This is a discussion on set autofillForm pref to true only for several websites - Mozilla ; Hello, I am working on an extension that is a king of password manager, but this extension will be active only with some urls. The extension use the login manager of mozilla ( https://developer.mozilla.org/en/ nsILoginManager) For these particular websites, I ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: set autofillForm pref to true only for several websites

  1. set autofillForm pref to true only for several websites

    Hello,

    I am working on an extension that is a king of password manager, but
    this extension will be active only with some urls. The extension use
    the login manager of mozilla (https://developer.mozilla.org/en/
    nsILoginManager)

    For these particular websites, I don't want that the login
    informations are auto filled in the form. I know how to force the
    autofillForm pref to false :

    var prefs = Components.classes["@mozilla.org/preferences-service;
    1"].getService(Components.interfaces.nsIPrefBranch);

    prefs.setBoolPref("signon.autofillForms", false);

    But this makes, of course, the autofillForm disabled for all
    websites.

    So, I have tried to detect the loading page and if the url is the url
    that interests me, try to set this pref to false, like that:

    var prefs = Components.classes["@mozilla.org/preferences-service;
    1"].getService(Components.interfaces.nsIPrefBranch);

    window.addEventListener("load", function () { gBrowser.addEventListener
    ("load", onPageLoad, true); }, false);

    function onPageLoad(event)
    {
    if (event.originalTarget instanceof HTMLDocument)
    {
    var currentUrl=gBrowser.selectedBrowser.currentURI.spe c;
    if(currentUrl="http://login.monsite.com")
    prefs.setBoolPref("signon.autofillForms", false);
    else
    prefs.setBoolPref("signon.autofillForms", true);
    }
    }

    But when the new page open, for which password has already been saved,
    the form is already filled. It seems that this pref has to be set
    before page is loading.

    So, how can I do that?
    Has somebody an idea?

    Thanks in advance

  2. Re: set autofillForm pref to true only for several websites

    I have still not find the solution to my problem but have noticed some
    new informations.

    I do not want to pre fill the login form for some websites of
    interest.

    In this first case:

    var prefs = Components.classes["@mozilla.org/preferences-service;
    1"].getService(Components.interfaces.nsIPrefBranch);
    prefs.setBoolPref("signon.autofillForms", true);
    function onPageLoad(event)
    {
    if(prefs.getBoolPref("signon.autofillForms")){
    alert("ok");
    }
    if (event.originalTarget instanceof HTMLDocument) {
    var currentUrl=gBrowser.selectedBrowser.currentURI.spe c;
    if(currentUrl="http://login.monsite.com") {
    }
    }
    }

    the alert message is displayed before the page is displayed, however,
    in this case:

    var prefs = Components.classes["@mozilla.org/preferences-service;
    1"].getService(Components.interfaces.nsIPrefBranch);
    prefs.setBoolPref("signon.autofillForms", true);
    function onPageLoad(event)
    {
    if (event.originalTarget instanceof HTMLDocument) {
    if(prefs.getBoolPref("signon.autofillForms")){
    alert("ok");
    }
    var currentUrl=gBrowser.selectedBrowser.currentURI.spe c;
    if(currentUrl="http://login.monsite.com") {
    }
    }
    }
    the alert message is displayed once the page is loaded, that means
    that the login form is already filled before the test on the url of
    the website.
    But I want to disable the autofillForms before the page is completely
    loaded (if the url is for example: "http://login.monsite.com"), in
    order to avoid that the login fields are prefilled.

    Is it possible?

    Thanks in advance for some help.

+ Reply to Thread