Neutral Axis

Make a custom bookmarklet for your library

by on Feb.01, 2013, under Uncategorized

I’ve found it kind of amazing how many non-mainstream CDs my local library has that I read about online.  Today I modified a bookmarklet I found for searching Amazon.com so it searches my local library.  It’s not hard, so you may be able to get it to work similarly for yours.

The Amazon bookmarklet I found is this:

javascript: q = "" + (window.getSelection ? window.getSelection() : document.getSelection ? document.getSelection() : document.selection.createRange().text); 
if (!q) q = prompt("Searchterms?...", ""); 
if (q != null) { 
 location = "http://www.amazon.com/exec/obidos/external-search?mode=blended&tag=bookmardirect-20&keyword=" + escape(q).replace( //g,"+");}else{location="http://www.amazon.com/exec/obidos/redirect-home/bookmardirect-20";}void0

I added that to my bookmarks bar in Chrome, right clicked it, edited it, and changed the name to “Search Library”.

At my library’s website I did a sample search for “targetbook” and this is the URL that resulted.

http://coolcat.org/search~S1/X?searchtype=X&searcharg=targetbook&Submit.x=0&Submit.y=0&Submit=Submit&SORT=D&searchscope=1

I tried an experiment and deleted everything after “targetbook” and still got a good search, so I’m not sure what those other parameters really do, but apparently they’re not too important in this case.

So I copied the important part to the clipboard,

http://coolcat.org/search~S1/X?searchtype=X&searcharg=

and edited the Amazon bookmarklet again, pasting that line in like this, over the first Amazon.com part.

javascript: q = “” + (window.getSelection ? window.getSelection() : document.getSelection ? document.getSelection() : document.selection.createRange().text); 

if (!q) q = prompt("Searchterms?...", ""); 
if (q != null) { 
 location = "http://coolcat.org/search~S1/X?searchtype=X&searcharg=" + escape(q).replace( //g,"+");}else{location="http://www.amazon.com/exec/obidos/redirect-home/bookmardirect-20";}void0

Then for the other Amazon address, which gets called if you haven’t selected anything to search for, I substituted the library’s basic address.  The final bookmarklet is this.

javascript: q = "" + (window.getSelection ? window.getSelection() : document.getSelection ? document.getSelection() : document.selection.createRange().text); 
if (!q) q = prompt("Searchterms?...", ""); 
if (q != null) { 
location = "http://coolcat.org/search~S1/X?searchtype=X&searcharg=" + escape(q).replace( //g,"+");}else{location="http://coolcat.org/search~s1";}void0

I left that “search~s1” on it because I determined that field brings up a particular city’s library system instead of other available in the county. It actually wouldn’t be necessary though.


Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...