Tibs Manor

Thursday, August 10, 2006

BGGreaseMonkey

(Download the script here.)

I ran into an annoyance with emailing my Flickr contacts a few days ago, which prompted me to install the GreaseMonkey Firefox extension, along with a script that solved the problem. If you read the comments on that page you'll see that I found a small bug and fixed it. From there it was a short step to wanting to write my own GreaseMonkey script for something. I settled on (surprise!) an enhancement to BoardGameGeek.

But first - what is GreaseMonkey, you may be asking? It basically allows you to execute JavaScript on existing webpages. There's a wealth of scripts available at userscripts.org, and if you know JavaScript you can write your own. You can fully modify the DOM, adding and removing elements from the page as you see fit. It also includes a way to make requests over http. So for instance, you could have a script that:

Anyway, my script takes an individual game profile page on BGG, and adds a link to do a price search. When you click the link, the script extracts the name and id of the game, queries a number of online retailers, and displays the results. Click the image below to see an animation of this in action. The problem is that as far as I know, none of these retailers have a way to search via BGG id, and so I have to make do with text searches. For a fairly unique name like Candamir or Tempus this works out pretty well, but searching for something like Ra on most of these sites will return hundreds of results. Even the fairly unique names can have problems on some retailers if there are multiple language editions, or a "ding & dent" special.

The script does display the name of the game, so if you search for "Ra" and the script finds "Affenraffen", you'll instantly see the issue. I added a way to edit the store-specific id's for each game, which is an annoying manual process to be sure. Best case scenario would be if I had some cheap webhosting with PHP or JSP or something and a database...that could keep a repository of user-corrected id's, and I could modify the GM script to work in conjunction with that. But even as it stands now, I tend to revisit pages over and over when I'm compiling a game order, so it's still worth the time for me to manually correct a few entries. And as I said, for some games it works great right out of the box.

(Download the script here.)

3 Comments:

  • Well, I installed GreaseMonkey and the script but it doesn't look like it's working. When I go to a game page, I don't see the link to do the price comparison.

    XP SP2
    Firefox 1.5.0.6
    GreaseMonkey 0.6.5.20050727

    By Blogger Boardgameplayer, at 7:26 PM  

  • Sorry about that - fixed it and re-uploaded to userscripts.org, if you reinstall the script it should work now.

    By Blogger Sir Tibs Tibsford, at 10:18 PM  

  • Great. It's working now. I'll let you know if I encounter any problems with it. Thanks!

    By Blogger Boardgameplayer, at 5:45 AM  

Post a Comment

<< Home