Matthew Wilson wrote:
I finally got round to writing a Greasemonkey script to persuade Firefox to remember my mailman passwords. I've attached it to this email - if the attachment doesn't get through to the list then I'll send another mail.

Tested with Firefox 1.5 + greasemonkey 0.6.4.

(The dummy username box could be placed in a more aesthetically pleasing position, but I didn't feel it was worth the effort.)

Version 0.2 works if you are managing multiple accounts. (With 0.1, when you loaded up your second project page, the password manager filled in the details for your first project.)

Matthew
// Mailman user script
// version 0.2
//
// --------------------------------------------------------------------
//
// This is a Greasemonkey user script.
//
// --------------------------------------------------------------------
//
// ==UserScript==
// @name          Mailman Password Manager
// @namespace     http://www.mozdev.org/
// @description   Inserts a fake 'username' field into mailman login screens, 
to allow Firefox password manager to work
// @include       http://mozdev.org/mailman/admindb/*
// @include       http://mozdev.org/mailman/admin/*
// ==/UserScript==

// Determine the project name (the part of the current URL after the last 
// slash to use as the user name.
var project = document.location.href;
project = project.substring (1+project.lastIndexOf("/"));

var form = document.getElementsByTagName ("form").item(0);

// Check whether this is the login form by looking for a
// form element named "adminpw"
var pwd = form.elements.namedItem("adminpw");

if (pwd != null) {
    var input = document.createElement ("input");
    input.setAttribute ("type", "text");
    input.setAttribute ("name", "user");
    input.setAttribute ("value", project);
    form.insertBefore (input, form.childNodes[0]);

    // So we've inserted a 'user' field whose value is the name of the project.
    // But if we've already set up an account for one project, then the password
    // manager will overwrite this username when the page has finished loading.
    // So we set up an onload handler, which waits for 200ms before checking
    // whether this has happened. If so, it rewrites the username, and clears
    // the password.
    window.addEventListener ("load", function () {
       window.setTimeout (function () {
           var project = document.location.href;
           project = project.substring (1+project.lastIndexOf("/"));
           var form = document.getElementsByTagName ("form").item(0);
           var pwd = form.elements.namedItem("adminpw");
           if (pwd != null) {
               var input = form.elements.namedItem("user");
               if (input != null && input.value != project) {
                   input.value = project;
                   pwd.value = "";
               }
           }
       }, 200);
    }, false);

}
_______________________________________________
Project_owners mailing list
[email protected]
http://mozdev.org/mailman/listinfo/project_owners

Reply via email to