Forza statistics user script update

I hacked around a little bit on the forza-stats user script, and ended up with this:

  • Added a "podium percentage" statistic. This takes the number of 1st, 2nd, and 3rd place finishes (or as I like to call them, "win, place, and show"), and divides them by the total number of races.
  • Added an onsubmit handler to the gamertag input form. If you hit enter on the input box, it will act as though you clicked "Set".
  • Changed the color and opacity of the statistics bar. I changed it to a greyish color that better fit the Forza theme, and added a slight transparency so that you can see the header graphic obscured by the bar. Strictly cosmetic, since the bar wasn't obscuring any clickable bits, but it's still a nice change.
  • Added some nasty browser-detection code so that the bar can be "position: fixed" on Mozilla. IE doesn't support "position: fixed", and the hacks to support a fixed-like layout assume you have full control over the web page. Since I really don't want to try to completely re-layout the Forza community pages, I did this hack so that at least Firefox users can have a fixed bar. I was very hesitant about adding this browser check, since it may completely fail if you've changed Firefox's userAgent string to mimic IE, but I decided it was worth doing because Firefox has reached the point where it's an accepted browser and only really stupid pages require it to identify itself as MSIE. Worst case, if you've changed Firefox's userAgent to look like MSIE, the statistic bar will be positioned abosolutely at the top of the page rather than as a "floating" fixed element.
  • Added some cleanup code to unhook onclick and onsubmit handlers. This is an attempt to help stem IE's javascript memory leaks. Memory is still leaked, but the forza-stats script should be nicer about not leaking as much memory.
I also spent some time seeing if I could make this script work with Opera 8's user scripting support, but reliance on GM_* functions makes this difficult. I tried using a script that implements the GM_* functions, but ran into several problems:
  1. The GM_getValue implementation in that script is broken. It's trying to eval the stored value, which doesn't work when storing simple strings.
  2. The GM_xmlhttpRequest "implementation" is simply an aliasing of Opera's XMLHttpRequest object. That's not enough for a proper implementation of GM_xmlhttpRequest.
If those two items in the compatibility script were fixed, or if a different compatibility library was used (I don't normally use Opera, so I don't know what exists in terms of mimicking Greasemonkey functions), forza-stats may work in Opera. However, given the differing CSS implementations across browsers, the bar itself probably wouldn't look right (Opera supports "position: fixed", but my browser check may not handle Opera properly; the width of the bar may be incorrect; Opera doesn't support the opacity style or the filter style which is used to do opacity in IE; etc).

As before, forza-stats is compatible with both Mozilla/Greasemonkey and IE/Turnabout.