The Code
This user script runs on all pages. First, it defines a helper function that neutralizes any autocomplete attribute on an HTML element. Then, it iterates over each form and each of its fields, calling into the helper function for the cleaning.
TIP
This feature was first available in the form of a bookmarklet, a small chunk of JavaScript embedded in a URL and saved as a bookmark. Compared to user scripts, bookmarklets are more difficult to edit and debug, and they do not execute automatically when a page loads. But bookmarklets do not require any additional software. User scripts are a natural evolution of bookmarklets.
Save the following user script as allow-password-remembering.user.js:
// ==UserScript==
// @name Allow Password Remembering
// @namespace http://blog.monstuff.com/archives/cat_greasemonkey.html
// @description Removes autocomplete="off" attributes
// @include *
// ==/UserScript==
// based on code by Julien Couvreur
// and included here with his gracious permission
var allowAutoComplete = function(element) {
var iAttrCount = element.attributes.length;
for (var i = 0; i < iAttrCount; i++) {
var oAttr = element.attributes[i];
if (oAttr.name == 'autocomplete') {
oAttr.value = 'on';
break;
}
}
}
var forms = document.getElementsByTagName('form');
for (var i = 0; i < forms.length; i++) {
var form = forms[i];
var elements = form.elements;
allowAutoComplete(form);
for (var j = 0; j < elements.length; j++) {
allowAutoComplete(elements[j]);
}
}