I hacked around a little bit on the forza-stats user script, and ended up with this:
Changes:![]()
- 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.
- 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.
- The GM_xmlhttpRequest "implementation" is simply an aliasing of Opera's XMLHttpRequest object. That's not enough for a proper implementation of GM_xmlhttpRequest.
As before, forza-stats is compatible with both Mozilla/Greasemonkey and IE/Turnabout.
Jeff Stone
is there a way to make it so the script will go out and get the stats regarless of what page you have open?
Todd
For now, I believe the bar insertion is pretty much tied into the Forza page layouts (I need to look at the script again, since I thought I changed that). You can certainly change your include list to * rather than just Forza Community pages, but I can't guarantee it'll continue to display properly. It wouldn't hurt to try.