swisspig.net - To hell with the pig... I'm going to Switzerland.

Hacking Firefox to Make Bank Sites Usable (Saturday, February 24, 2007)

So, I was whining about having to type in my account number on one screen, and then type in my password on another screen, despite my insistence that I really do want my browser to remember them. As it turns out, my little autocomplete hack was working for the password. But the browser wasn't recognizing a field by itself with no associated password as a username field, but rather as a search box, or something like that.

Since the built-in form completion in Firefox is designed for stuff like search boxes, and not for automatically filling in a lonely user name, I downloaded AutoFormer, which allows you to save the contents of a field via a context menu, and have it automatically fill it in for you next time.

You'd think that would have been the end of it. But no, my bank, in all of its wisdom, has a script that waits until the page loads, and then explicitly clears the text field. And because it uses broken HTML, instead of modern standard HTML, it chose to use the onload attribute of the BODY tag. And this is executed after the load handler that AutoFormer registered properly, via the addEventListener() function.

What a pain. So I used GreaseMonkey, another nifty Firefox toy, to automatically turn the onload handler into a properly registered event handler. Unfortunately, javascript does not provide a way to specify the order that they are handled, and so the AutoFormer handler was still called first, causing it to fill in the form value, and then the default would run second, clearing the form value.

I tried modifying AutoFormer so that it would call the default handler first, before running its own thing (i.e. making sure it's the final handler to run), but every time I tried to change it, it would stop loading itself. There's probably some cute little "don't change me" aspect that I didn't see, but in any event, I abandoned that, and in the end, I put in a relatively simple GreaseMonkey script that removes the line of code that clears the text area.

It works, but I should send a bill to my bank for the lost afternoon. What a pain. In a nutshell, here is the user script I wrote:

    var oldload;
    function newload(event) {
        var target = event ? event.target : this;
        oldload = oldload.replace('initialize();', 
                                '/* how about no */');
        unsafeWindow.eval(oldload);
    }

    function redefineload() {
        var els = document.getElementsByTagName('body');
        for(i=0;i<els.length;i++) {
            var x = els[i];
            for(j=0;j<x.attributes.length; j++) {
                if(x.attributes[j].name.toLowerCase() == 'onload') {
                    oldload = x.attributes[j].value;
                    x.attributes[j].value = '';
                    // instead do this
                    window.addEventListener('load', newload, true);
                }
            }
        }

    }
    redefineload();
—Brian (2/24/2007 5:33 PM)
(0 comments)

Comments

No comments.

Name
URL
Comment
(no html)
 

Disclaimer: Opinions on this site are those of Brian Ziman and do not necessarily
reflect the views of any other organizations or businesses mentioned.