The "My account" page on the Calgary Public Library site uses your library card number and a pin number to authenticate you. However, both form fields are of type "password", which means that Firefox won't save the username / password information. Since the site seems to randomly log you out, it becomes a pain in the ass to get out the library card over and over again to type it in by hand.
This Greasemonkey script simply changes the library card barcode number field from a password type to a text type, which allows Firefox to remember the contents. Unfortunately, when Firefox fills the form, it places the "password" (your pin) in the first password field it finds... since the autofill happens before the Greasemonkey script runs. The barcode isn't autofilled anywhere, so it is necessary to embed it in the script itself. Or you can type the first number in the barcode field and it will autofill it then.
NOTE: after using the CPL website a while, I noticed that the original version of this script was filling in random form fields. It needed to be modified to look for some unique characteristic of the sign in page. Since the CPL website uses a single JSP and GET URL parameters to navigate all the pages, one can't use the greasemonkey include/exclude URL thing.
// ==UserScript==
// @name Calgary Public Library Login fixer
// @namespace http://spacemonkeys.ca/greasemonkey
// @description Changes the password box to a text box so
// that firefox can remember the form fields.
// @include https://catalogue.calgarypubliclibrary.com/ipac20/*
// ==/UserScript==
var inputFields = document.getElementsByTagName('input');
var barcode = inputFields[9];
var barcodeLabel = barcode.parentNode.parentNode.childNodes[0].childNodes[0];
var pin = inputFields[10];
var pinLabel = pin.parentNode.parentNode.childNodes[0].childNodes[0];
var mycardNumber = "xxxxxxxxxxxxxx";
// Firefox autofills the pin into the barcode field, probably because
// that is the first password field it sees. The barcode itself is lost.
if (pin.name == "sec2"
&& barcode.name == "sec1"
&& barcodeLabel.data.search("Library Card Number:") != -1
&& pinLabel.data.search("Last 4 numbers") != -1)
{
var temp = barcode.value;
barcode.value = mycardNumber;
pin.value = temp;
// Make the barcode number a text field, so that Firefox will be able
// to remember the barcode/pin combo.
barcode.type = 'text';
}
It looks like the CPL is in the middle of overhauling their site, so maybe the need for this script will go away.
If anyone can tell me how to get Firefox to redo the autofill after changing the barcode field to text, that would be great!