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 NBA.com 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 NBA.com, 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"));
});
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s