[Firefox] Supprimez la notification d’enregistrement de mot de passe (FF 3.6.8)

Suite au billet [Firefox] Sauvegardez tous les mots de passe sans notification, publié il y a quelques jours, certains d’entre vous ont remarqué que le hack proposé ne fonctionne pas. J’ai mis à jour le code pour le rendre à nouveau fonctionnel.

D’autres s’inquiétaient du fait que cela permettait d’enregistrer les mots de passe sans le consentement des internautes. C’est la cas. C’est pourquoi je propose cette autre technique, plus soft, qui supprime simplement l’apparition du bandeau, sans enregistrer les mots de passe.

Voici donc le nouveau hack, testé avec FF 3.6.8, la dernière version sortie lors de l’écriture de ce billet.

Avant tout, faites une copie de votre fichier nsLoginManagerPrompter.js.

Il se trouve normalement sous le répertoire:

  • Windows: Program FilesMozilla Firefoxcomponents
  • Mac: Firefox.appContentsMacOScomponents (accessible en faisant un clic droit sur le répertoire d’installation de Firefox et en choisissant « Show Package Contents« 
  • Linux: Il faut chercher car cela varie beaucoup mais en général c’est sous /usr/lib/firefox-3.6.x/components/ (merci à scalp pour l’info). Remplacez le x par votre version.

Ensuite, ouvrez le fichier nsLoginManagerPrompter.js dans un éditeur de texte digne de ce nom (Notepad++ par exemple).

Ensuite cherchez le code suivant (sous Firefox 3.6.8, ce sont les lignes 763 à 787) :

_showLoginNotification : function (aNotifyBox, aName, aText, aButtons) {
        var oldBar = aNotifyBox.getNotificationWithValue(aName);
        const priority = aNotifyBox.PRIORITY_INFO_MEDIUM;

        this.log("Adding new " + aName + " notification bar");
        var newBar = aNotifyBox.appendNotification(
                                aText, aName,
                                "chrome://mozapps/skin/passwordmgr/key.png",
                                priority, aButtons);

        // The page we're going to hasn't loaded yet, so we want to persist
        // across the first location change.
        newBar.persistence++;

        // Sites like Gmail perform a funky redirect dance before you end up
        // at the post-authentication page. I don't see a good way to
        // heuristically determine when to ignore such location changes, so
        // we'll try ignoring location changes based on a time interval.
        newBar.timeout = Date.now() + 20000; // 20 seconds

        if (oldBar) {
            this.log("(...and removing old " + aName + " notification bar)");
            aNotifyBox.removeNotification(oldBar);
        }
    },

 
Changez ces lignes par les suivantes :

_showLoginNotification : function (aNotifyBox, aName, aText, aButtons) {
        var oldBar = aNotifyBox.getNotificationWithValue(aName);
        const priority = aNotifyBox.PRIORITY_INFO_MEDIUM;

        this.log("Adding new " + aName + " notification bar");
        /*var newBar = aNotifyBox.appendNotification(
                                aText, aName,
                                "chrome://mozapps/skin/passwordmgr/key.png",
                                priority, aButtons);

        // The page we're going to hasn't loaded yet, so we want to persist
        // across the first location change.
        newBar.persistence++;

        // Sites like Gmail perform a funky redirect dance before you end up
        // at the post-authentication page. I don't see a good way to
        // heuristically determine when to ignore such location changes, so
        // we'll try ignoring location changes based on a time interval.
        newBar.timeout = Date.now() + 20000; // 20 seconds*/

        if (oldBar) {
            this.log("(...and removing old " + aName + " notification bar)");
            aNotifyBox.removeNotification(oldBar);
        }
    },

En gros il suffit de commenter l’invocation du bandeau.

Enregistrez et relancez Firefox. Normalement vous ne devriez plus voir apparaitre ce bandeau.