NBA game recaps, not game info!

With reference to this post, I decided to write my first Greasemonkey script.

I don’t subscribe to cable TV, so I get my sports news fix mostly by reading. Now that the NBA playoffs are in progress, I use on a daily basis to read recaps like this one. I’m upset enough that the Lakers — one of the eight teams I’m rooting for — lost, without having to right-click “Game Scoreboard”, copy the link, and replace “gameinfo.html” with “recap.html” — which is what I’m most interested in, since I didn’t watch the match.

This is a pain, and since I can’t control, I’ve written nba_recap_not_gameinfo, a Greasemonkey userscript to do it automatically for me.

This uses the excellent jQuery, of course, and since this blog does programming-related posts, we’ll take at the important (super-simple) part consists of just 3 lines of Javascript.

So we’ll look for a descendants of span with class “gamelinks”, and then we regex-replace “gameinfo” with “recap”.

jQuery("span.gamelinks a").each(function() {
var $this = $(this);
$this.attr("href", $this.attr("href").replace(/gameinfo/, "recap"));

#firefox, #greasemonkey, #jquery