On a Roll
August 19th, 2007 | Published in development
I posted another Greasemonkey script last night. This one puts a link to search Google Products on Amazon pages, based on the name of the item you’re viewing. It’s more complicated than the last one, but it didn’t take too much time to throw together. I realize that I’m pretty late to the Greasemonkey party, but I’m having fun, and isn’t that the point?
One thing that bugged the hell out of me when working on this script is that it seems like Amazon adds absolutely no semantic meaning to their product pages. Does the product name sit in an element with an ID clearly labeling it as such? No. Here’s the XPath I had to use to extract the name:
//div[@class='buying']/b[@class='sans']
Isn’t that cheesy? It feels really fragile. I suppose I could have parsed the page title to strip out extraneous information, but I wouldn’t feel much better.
Update:
Surprise, surprise! It is fragile. The different templates that Amazon uses based on product category (I think?) break the script. Oh, well, at least it doesn’t fail spectacularly.
Known good:
- Books
- Music
- Electronics
Known bad:
- DVD