Recently in userscripts Category

I've updated the depiq user script, now version 2, to support Slashdot's recent HTML 4.0 + CSS site redesign. You'll want to remove the old script, as the script name has changed to represent the version update.

While the change is nice, and fixes some weird HTML (why was the first article on a page different than all of the rest), they still haven't made it very nice. For example, they have a div with an id of "articles", which you would think contains a bunch of articles. That it does, but it also contains storylinks (the "Read more" links under each article) and some other crap. Why doesn't an article encompass its own storylinks? Why are there other bits at the end of the div, like the "Yesterday's news" link? Oh well, I'll keep at it so long as they keep posting Roland stories.

Depiq user script update

I've updated the depiq user script. I've solved the problem of disembodied "Read More" links (Slashdot's HTML is FUBAR; the first story on a page is encapsulated in a paragraph except for its "Read More" bits, while subsequent stories on a page do not have the same parent paragraph). Because I'm more confident about the script's capabilities now, I've also changed the include list to handle all slashdot categories. Internally, I removed the closure (closures are not memory-friendly in IE), refactored the code a bit into functions, and added some logging (through the GM_log() functionality, you'll see it either in the Turnabout console in IE or the Javascript console in Firefox) to track the editor that posted each story that was found and to give a total count of how many stories were removed. Finally, I can't seem to keep the filenames straight. I'm sticking with "depiq.user.js" for now. You may have to uninstall the previous script before installing this new one.

As always, the script has been tested with IE/Turnabout and Firefox/Greasemonkey. Since this script is just basic DOM walking and manipulation, it should work in Opera 8 as well, but I've not done any testing there.

Depiq user script

Since I created a "userscripts" category on my blog, I figured I should post my other user scripts (okay, "user script" singular for now) in this category for easy access.

Here's the depiq user script. It removes Roland Piquepaille-submitted stories from the Slashdot home page (exactly why you would want to remove these submissions is explained in the comments of pretty much every Roland-submitted story -- ie, if you have to ask, you probably don't care enough to remove them). The inclusion list is only the main Slashdot page, so Roland stories will still show up in other sections (you could change the inclusion list, but I haven't tested that). It's not perfect, thanks to Slashdot's horribly awful HTML code. You might see some parentless "Read More" links, for example. That just tells you that the script is working.

Since I'm an Internet Explorer user (gasp!), this script works with both Firefox/Greasemonkey and IE/Turnabout (Turnabout is now my choice of Greasemonkey-like IE plugins, since I killed GreasemonkIE -- I really liked that name; maybe Turnabout could rename themselves to GreasemonkIE?). It might work in Opera 8, but I haven't tested it there. Feel free to let me know if it does or doesn't work, or update the script to work with Opera.

Any future scripts will be Firefox/Greasemonkey- and IE/Turnabout-compatible. I'll do my best to support Opera 8, but it's secondary to the other two (sorry, Opera users).

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.
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.

Forza statistics user script

The Forza team recently launched their online stats for Forza Motorsports. The stats are still a bit rudimentary, and there's no way to log in to get a brief overview of your own statistics a la Bungie's Halo 2 stats. However, there is a GET interface to retrieve gamertag details.

Enter Greasemonkey/Turnabout. I wrote a user script to add a bar to the top of the Forza community pages displaying some information about a given gamertag.

The bar displays the current gamertag with a link to its statistic page, and the tag's ELO, 1st place races, 2nd place races, 3rd place races, and total races. You can refresh your statistics at any time (this currently works best in Firefox with Greasemonkey -- you may have to click Refresh multiple times in IE with Turnabout), check on the statistics of another gamertag (type the tag into the input box and click "Check" to navigate to that tag's stat page), or set your a different gamertag to track (type the tag into the input box and click "Set"). After installation, you'll notice that the bar says "No tag". You need to set a gamertag for it to watch.

Caveat: Like Bungie's Halo 2 statistics, the Forza statistics may occasionally be out of sync with the actual Xbox Live data. This can manifest itself a simply not finding any statistics at all, or finding only partial statistics (ELO, but no race numbers), or it might just not reflect your most recent races (ELO changes, race count increases). You can try Refreshing the stat bar data, or Checking your gamertag's statistic page to see if the data has been synced up yet.

Hopefully a more robust data source will be available for Forza stats (RSS, please!), and hopefully even more statistics will be forthcoming.

About this Archive

This page is an archive of recent entries in the userscripts category.

other is the previous category.

Find recent content on the main index or look in the archives to find all content.

Ads

Pages

OpenID accepted here Learn more about OpenID
Powered by Movable Type 5.01