// Bookburro Ajax Panel for GreaseMonkey and Turnabout // @version 0.18 /* (C) 2005 Johan Sundström (0.13 .. 0.18) License: Creative Commons "Attribution-ShareAlike 2.0" http://creativecommons.org/licenses/by-sa/2.0/ Skeletal parts of DOM-Drag by Aaron Boodman, 2001 http://www.youngpup.net/2001/domdrag License: Creative Commons "Attribution-ShareAlike 2.0" http://creativecommons.org/licenses/by-sa/2.0/ (C) 2005 Reify (0.11r .. 0.12r) License: Creative Commons "Attribution-ShareAlike 1.0" http://creativecommons.org/licenses/by-sa/1.0/ (C) 2005 Jesse Andrews, Britt Selvitelle under cc-by-sa (0.01 .. 0.11) License: Creative Commons "Attribution-ShareAlike 1.0" http://creativecommons.org/licenses/by-sa/1.0/ Snipits used from RSS Reader for GreaseMonkey http://www.xs4all.nl/~jlpoutre/BoT/Javascript/RSSpanel/ Version: 1.03 (C) 2005 Johannes la Poutre THANKS! Changelog: * 2006-01-09 * 0.18 - Added bookpool.com, contributed by Pallando. * 2005-11-02 * 0.17 - Added Google Print. Initial preparations for ISBN-13, for Jan. 1, 2007. * 2005-10-04 * 0.16 - Bugfix for Greasemonkey 0.53 -- for now, only open/close/drag the title * 2005-10-03 * 0.15 - Added BiggerBooks.com, Bookbyte, Booksamillion.com and eCampus.com * 2005-10-02 * 0.14 - Made the bookburro window draggable - Added (one hour) price cache for last seen book - Added Abebooks, Alibris, biblio.com, cdon.com, exlibris.se and libris.se - Centralized all (functionally important) code dealing with each store - Integrated my improvements with the Reified version 0.12r codebase - Added option to update book URL when fetching price tag / Johan Sundström, oyasumi+bookburro@gmail.com * 2005-09-19 * 0.13 - GreaseMonkey 0.6 compatibility fix to get working onclick handlers - Added AJAX fetching from Powell's Books, figuring they want customers - Added adlibris.se, akademibokhandeln.se, bokus.com and internetbokhandeln.se - For kicks, added availability listing at Linköping University library / Johan Sundström, oyasumi+bookburro@gmail.com * 2005-06-24 * 0.12x - Added support for alldirect.com * 2005-06-21 * 0.12r - works when injected before the page has finished loading; fixed price-parsing on Powells.com; removed Powells from list in the Burro box 0.11r - modified by Reify to work in Internet Explorer with Turnabout: - The price wouldn't render on Amazon for some reason, so we now render with DIVs + SPANs - Set style in a way that works in IE (element.setAttribute("style", str) doesn't work in IE) - Moved data: URIs to one place to make the script easier to read - Show/hide the price table rather than changing the box's dimensions to make code easier to maintain (don't have dimensions scattered throughout) - Anchored top right icons to the top right instead of top left so their position will update automatically if the box has to be wider - Branch to use MS or Mozilla XML parser * 2005-04-25 * 0.11 - improved skin & add link to message if no results 0.10 - bug fix - don't show iframes! 0.09 - bug fix - alert were out of scope, plus a couple visual tweaks 0.08 - bug - use (function(){ code })(); so you don't kill other javascript 0.07 - use AWS to grab amazon's prices * 2005-04-24 * 0.06 - wasn't checking for ISBN= in the url as well! 0.05 - added Amazon marketplace 0.04 - worked on skin to make it PURTY 0.03 - use AJAX to add the prices 0.02 - Improved interface 0.01 - initial releasea */ // ==UserScript== // @name Book Burro - Remixing the bookstore // @namespace http://overstimulate.com/userscripts/ // @description Compare book prices from various book stores // @include http://amazon.com/* // @include http://www.amazon.com/* // @include http://www.powells.com/* // @include http://half.ebay.com/* // @include http://buy.com/* // @include http://www.buy.com/* // @include http://biblio.com/* // @include http://www.biblio.com/* // @include http://search.barnesandnoble.com/* // @include http://barnesandnoble.com/* // @include http://www.barnesandnoble.com/* // @include http://www.alldirect.com/* // @include http://www.bokus.com/* // @include http://www.internetbokhandeln.se/* // @include http://www.akademibokhandeln.se/* // @include http://akademibokhandeln.se/* // @include http://www.adlibris.se/* // @include http://*.bibl.liu.se/* // @include http://www.cdon.com/* // @include http://www.exlibris.se/* // @include http://www.libris.se/* // @include http://www.alibris.com/* // @include http://bookbyte.com/* // @include http://www.bookbyte.com/* // @include http://biggerbooks.com/* // @include http://www.biggerbooks.com/* // @include http://ecampus.com/* // @include http://www.ecampus.com/* // @include http://www.booksamillion.com/* // @include http://print.google.com/* // @include http://www.bookpool.com/* // @include http://bookpool.com/* // ==/UserScript== var debug = 0; // You are welcome either to put your own affiliate codes and dev keys below, // or to leave them as is, sponsoring further development of this application var abebooks_aid = 10395338, abebooks_pid = 1814912; var amazon_associate_code = 'diaryohayou-20'; var amazon_dev_key = '05GK2S0SFN8G8P5KY482'; var bn_associate_code = 41532291; var half_associate_code = 1814912; // (CJ PID, really -- not your CJ account number!) // Of these, only name, id and bookURL are mandatory (but hostname, getISBN, ajaxURL and ajaxPrice are usually needed too). // name: book store name listed in burro window // id: a short unique id string for all document nodes related to this book store // hostname: a hostname regexp used to determine whether to look for ISBNs on this page // bookURL: address to link the name to, %s being replaced with the ISBN of the book // getISBN: function run on book store pages to find the book ISBN it's about; returns false (no book), or an ISBN string // -- or -- regexp applied to the full URL of the page, whose first matched paren pair gives the ISBN of the book shown // -- defaults to /isbn[\/=]([0-9X]{10})(&|\?|\.|$)/i if omitted // ajaxURL: address to pick up price for the book whose ISBN is %s, for ajax handler (defaults to bookURL, if not given) // ajaxData: '' by default; if given, the data to provide with the ajax request body, %s replaced with the ISBN of the book // ajaxMethod: POST by default (if not given); which HTTP method to access the above // ajaxHeaders: HTTP headers for the AJAX request. Adds a Content-Type: 'application/x-www-form-urlencoded' header for all // POST requests missing a content-type declaration. // ajaxPrice: function run on fetched AJAX page to get book price; returns false (not found) or a price and currency string // or an associative array from store id to price and currency string, when one AJAX request can get many prices // -- or -- regexp (or string form, the latter mostly useful avoid quoting /:s) whose first paren picks up the book price // -- or -- false, in which case no xmlHTTPRequest is ever made (for instance because some other handler finds the price) // priceFix: if ajaxPrice was a string and this function is provided, the resulting price is fed through the callback // updateURL: if provided, a function run on the fetched AJAX page, to get a new (or proper) URL for the book link var handlers = [ { name: 'Abebooks.com', id: 'abebooks', hostname: /\babebooks.com$/i, getISBN: /(?:isbn|bi)=([0-9X]{10})(&|\?|$)/i, bookURL: 'http://www.abebooks.com/servlet/SearchResults?isbn=%s&pid='+ abebooks_pid +'&aid='+ abebooks_aid, ajaxPrice: /\D*(\$[^<]*)/i }, { name: 'Ad Libris', id: 'alse', hostname: /\badlibris\.se$/i, bookURL: 'http://www.adlibris.se/shop/product.asp?isbn=%s', ajaxPrice: function( html, http ) { if( html.match( 'Ingen titel med detta ISBN finns hos AdLibris.' ) ) return ''; return SEK( html.match( '([^<]*)<' )[1] ); } }, { name: 'Akademibokhandeln', id: 'abse', hostname: /\bakademibokhandeln\.se$/i, getISBN: nextSameTagAfter( 'td', '^ISBN' ), updateURL: firstLinkTo( 'cc_artikel.visa_artikelkort', 'http://www.akademibokhandeln.se/db/caweb/' ), bookURL: 'http://www.akademibokhandeln.se/db/caweb/sok.avanc_artiklar?mtitel=exact&cisbn=%s', ajaxPrice: /\s*([^<]*)([^<]*)]*>([^<]*)' }, { name: 'Biblio.com', id: 'biblio', hostname: /\bbiblio\.com$/i, bookURL: 'http://www.biblio.com/isbn/%s.html', ajaxMethod: 'GET', ajaxPrice: /