--- 0.11.user.js 2005-09-30 20:42:36.000000000 +0200 +++ bookburro.user.js 2005-09-19 23:58:05.000000000 +0200 @@ -1,7 +1,7 @@ /* Bookburro Ajax Panel for GreaseMonkey - Version 0.11 + Version 0.13 (C) 2005 Jesse Andrews, Britt Selvitelle under cc-by-sa License: Creative Commons "Attribution-ShareAlike 1.0" http://creativecommons.org/licenses/by-sa/1.0/ @@ -12,6 +12,17 @@ THANKS! Changelog: + * 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.12 - Added support for alldirect.com * 2005-04-25 * @@ -44,6 +55,13 @@ // @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/* // @exclude // ==/UserScript== @@ -121,14 +139,14 @@ return money; } -var amazon_associate_code = 'anotherjesse-20' // PUT YOUR AMAZON ASSOCIATE CODE HERE !!!! +var amazon_associate_code = 'diaryohayou-20' // PUT YOUR AMAZON ASSOCIATE CODE HERE !!!! var amazon_dev_key = '0XYJJ825QSB9Q7F2XN02'; // PUT YOUR AMAZON DEV KEY HERE !!! var bn_associate_code = '41456445'; /// PUT YOUR BN AFFILIATE CODE HERE!!! var half_associate_code = '1698206-1932276'; /// PUT YOUR HALF AFFILIATE CODE HERE!!! function run_queries(isbn) { - var errmsg = 'Either there are no books available,\\nor there is a parsing error because of\\nsome change to their website.\\n\\nNot everyone has a nice webservice like Amazon'; + var errmsg = 'Either there are no books available,\\nor there is a parsing error because of\\nsome change to their website.'; ////// AJAX for BN.com ///// @@ -160,6 +178,16 @@ } }); + ////// AJAX for alldirect.com ///// + + GM_xmlhttpRequest({ method:"POST", url:'http://www.alldirect.com/book.asp?&isbn='+isbn, data:"", + onload:function(result) { + try { + document.getElementById('burro_alldirect').innerHTML = result.responseText.match('All Direct\x27s[^P]*Price[^\$]*\([^<]*\)<')[1]; + } catch (e) { document.getElementById('burro_alldirect').parentNode.innerHTML = 'none'; } + } + }); + ////// AJAX for both amazon.com ///// GM_xmlhttpRequest({ method:"POST", url:'http://xml.amazon.com/onca/xml3?t=' + amazon_associate_code + '&dev-t=' + amazon_dev_key + '&type=lite&f=xml&mode=books&AsinSearch='+isbn, data:"", @@ -180,8 +208,83 @@ } }); - var msg = 'We want to check with them regarding the traffic of querying for prices from their site on every click...'; - document.getElementById('burro_powell').parentNode.innerHTML = '(info)'; + ////// AJAX for powells.com ///// + + GM_xmlhttpRequest({ method:"GET", url:'http://www.powells.com/cgi-bin/biblio?isbn='+isbn, + onload:function(result) { + try { + document.getElementById('burro_powell').innerHTML = result.responseText.match('
([^<]*)<')[1]; + } catch (e) { document.getElementById('burro_powell').parentNode.innerHTML = 'none'; } + } + }); + + ////// AJAX for bokus.com ///// + + GM_xmlhttpRequest({ method:"GET", url:'http://www.bokus.com/cgi-bin/book_search.cgi?FAST_VALUE=ISBN&FAST='+isbn, + onload:function(result) { + try { + document.getElementById('burro_bokus').innerHTML = result.responseText.match('([^<]*)<')[1].replace(/:-/,' SEK'); + } catch (e) { document.getElementById('burro_bokus').parentNode.innerHTML = 'none'; } + } + }); + + ////// AJAX for internetbokhandeln.se ///// + + GM_xmlhttpRequest({ method:"GET", url:'http://www.internetbokhandeln.se/_114K3FPUVX/msearchres.html?s_sortby=b&s_media=ALL&s_type=i&s_search='+isbn, + onload:function(result) { + try { + document.getElementById('burro_ibse').innerHTML = result.responseText.match('([^<]*)<')[1].replace(/:-/,' SEK'); + } catch (e) { document.getElementById('burro_ibse').parentNode.innerHTML = 'none'; } + } + }); + + ////// AJAX for akademibokhandeln.se ///// + + GM_xmlhttpRequest({ method:"GET", url:'http://www.akademibokhandeln.se/db/caweb/sok.avanc_artiklar?cisbn='+isbn, + onload:function(result) { + try { + document.getElementById('burro_abse').innerHTML = result.responseText.match('([^<]*)<')[1].replace(/\s/g,'').replace(/kr/,' SEK'); + } catch (e) { document.getElementById('burro_abse').parentNode.innerHTML = 'none'; } + } + }); + + ////// AJAX for adlibris.se ///// + + GM_xmlhttpRequest({ method:"GET", url:'http://www.adlibris.se/shop/product.asp?isbn='+isbn, + onload:function(result) { + try { + var html = result.responseText; + if( html.match( 'Ingen titel med detta ISBN finns hos AdLibris.' ) ) + fail(); + document.getElementById('burro_alse').innerHTML = html.match('([^<]*)<')[1].replace(/:-/,' SEK'); + } catch (e) { document.getElementById('burro_alse').parentNode.innerHTML = 'none'; } + } + }); + + ////// AJAX for bibl.liu.se ///// + + GM_xmlhttpRequest({ method:"GET", url:'http://hip.bibl.liu.se/ipac20/ipac.jsp?menu=search&index=ISBN&term='+isbn, + onload:function(result) { + var book, inne = 0, ute = 0, html = result.responseText; + while( book = /(.*?)<\/tr>/gi.exec( html ) ) + if( !book[1].match( /referens/i ) ) + if( book[1].match( /tillg|reserverad/i ) ) + inne++; + else + ute++; + if( inne+ute ) + { + html = inne; + if( ute ) + html += ' (of '+(inne+ute)+')'; + else + html += ' in'; + document.getElementById('burro_liubibl').innerHTML = html; + } + else + document.getElementById('burro_liubibl').parentNode.innerHTML = 'none'; + } + }); } @@ -189,7 +292,7 @@ function burro( location, isbn ) { var box = document.createElement("div"); box.setAttribute("title","Click box to expand/collapse"); - box.setAttribute("style","position:fixed;z-index:99;top:15px;left:15px;background-color:#ffc;border:1px solid orange;padding:4px;text-align:left;opacity:.85;font:8pt sans-serif;overflow:hidden;width:200px;height:15px;margin-bottom:15px;"); + box.setAttribute("style","position:fixed;z-index:99;top:15px;left:15px;background-color:#ffc;border:1px solid orange;padding:4px;text-align:left;opacity:.85;font:8pt sans-serif;overflow:hidden;width:220px;height:15px;margin-bottom:15px;"); var carrot = document.createElement("img"); carrot.setAttribute("style", "top:-10px"); carrot.setAttribute("src", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAALCAYAAACprHcmAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH1QQYCR020Q08hgAAAB10RVh0Q29tbWVudABDcmVhdGVkIHdpdGggVGhlIEdJTVDvZCVuAAAAiklEQVQY07XPIQoCURSF4e8NAzYxGicNuAa1WlyCO3AlZnfiNgwahQFxikkcBIsGfaZpzgODJ/4c/nMvPyR8g7EsephgH6q6aXnWIelhjkUsi0EL88TqFUfMYlnscMoS5wUccMYS4yxhfuGNPho88oQ5xxQjrHHpKkcMccMqVPU99eATG2zb4n/zAS4OHrV1hIB/AAAAAElFTkSuQmCC"); @@ -209,10 +312,10 @@ var close = document.createElement("img"); close.setAttribute("src", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAuJAAALiQE3ycutAAAAB3RJTUUH1QQYCDcSg6d+SAAAAPBJREFUKM+Fkr1qAkEURs9dnWBrJT5IHkEw4gtEsBQs/AlpkiKlJGnEJlqIjRbrPoAQYhPio1hGsPAHFoW5KSIxo7J7qvlgDty534j6Rolgt987OQnA7XuEsTuegwIeMYiIkx2hVnsjCL7+su9/0mz2Lox0oNOpUiw+kc2mUVWGww8mkxYiYK09F4xJMho9kMs9IiJMpy8Y83vFWkUTCVcAWCxWLJcrRIT1OiSTOczuCXieK2y3IeXyK4PBPZtNSKn0zGzWJpW6uvyGer1LpVIgn78GYD7/ptHo0e/fHbemvtHIHv4zvonv4ayXuK9xyg8qt0tfe9qKPAAAAABJRU5ErkJggg=="); - close.setAttribute("style", "position:absolute;left:190px;top:3px;margin:2px;width:12px;height:12px;background-color:#ffb;border:none;line-height:8px;text-align:center;"); + close.setAttribute("style", "position:absolute;left:210px;top:3px;margin:2px;width:12px;height:12px;background-color:#ffb;border:none;line-height:8px;text-align:center;"); close.setAttribute("title","Click To Remove"); - - close.onclick = function() { this.parentNode.style.display = "none"; }; + + close.addEventListener( 'click', function() { this.parentNode.style.display = "none"; }, true); box.appendChild(close); var about = document.createElement("a"); @@ -220,24 +323,29 @@ about_img.setAttribute("border", "0"); about_img.setAttribute("src", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAuJAAALiQE3ycutAAAAB3RJTUUH1QQYCDkprC+64gAAAOdJREFUKM+FkrFOAkEURc9ddrJZCgsqCwtCIiUFJa2df2CwNXRS8AmGisLEaGGs3VhTYDUtxZaED/AriGHjPhuEDC5wq3l5czL3vjeyzBlHtC6KoI4BuPk8Qqx3549rov3+YPBIp3NHq3VLlnkkBf0AWK2+6fevWCze8H7CaPRKUfzgnKsG0jSh272kLEuWyy/a7QvSNKnIsJEk6vWE2SxnPH5nOn3YWopjh9VqIbDBGA5fyPNnGo2znZVIEEWhJTNDgmbzfHvZzA6H/pP3k3/TqQQkIYle7z6oT74wnz8d3KNOfY19/QKFiTrWqbiPtAAAAABJRU5ErkJggg=="); about.appendChild(about_img); - about.setAttribute("style", "position:absolute;left:175px;top:3px;margin:2px;width:12px;height:12px;background-color:#ffb;border:none;line-height:12px;text-align:center;text-decoration:none;"); + about.setAttribute("style", "position:absolute;left:195px;top:3px;margin:2px;width:12px;height:12px;background-color:#ffb;border:none;line-height:12px;text-align:center;text-decoration:none;"); about.setAttribute("title","OverStimulate"); about.setAttribute("href","http://overstimulate.com/articles/2005/04/24/greasemonkey-book-burro-find-cheap-books" ); box.appendChild(about); var table = document.createElement("table"); table.setAttribute("style", "padding:0 5px;width:100%;font:10pt sans-serif;"); + table.appendChild( add_site( 'http://www.adlibris.se/shop/product.asp?isbn=' + isbn, 'Ad Libris', 'burro_alse' )); + table.appendChild( add_site( 'http://www.akademibokhandeln.se/db/caweb/sok.avanc_artiklar?cisbn=' + isbn, 'Akademibokhandeln', 'burro_abse' )); + table.appendChild( add_site("http://www.alldirect.com/book.asp?&isbn=" + isbn, "AllDirect.com", "burro_alldirect")); table.appendChild( add_site("http://www.amazon.com/exec/obidos/ASIN/" + isbn + "/" + amazon_associate_code, "Amazon", "burro_amazon" )); table.appendChild( add_site("http://www.amazon.com/exec/obidos/redirect?tag="+amazon_associate_code+"&path=tg/stores/offering/list/-/"+isbn+"/all/", "Amazon (used)", "burro_amazonmarket" )); table.appendChild( add_site( 'http://service.bfast.com/bfast/click?bfmid=2181&sourceid=' + bn_associate_code +'&bfpid=' + isbn + '&bfmtype=book', "Barnes & Noble", "burro_bn")); + table.appendChild( add_site( 'http://www.bokus.com/b/' + isbn + '.html', "Bokus", "burro_bokus")); table.appendChild( add_site("http://www.buy.com/retail/GlobalSearchAction.asp?qu=" + isbn, "Buy.com", "burro_buy")); - table.appendChild( add_site( 'http://www.tkqlhce.com/click-'+half_associate_code+'?ISBN=' + isbn, 'Half.com', 'burro_half' )); + table.appendChild( add_site( 'http://www.internetbokhandeln.se/_114K3FPUVX/msearchres.html?s_sortby=b&s_media=ALL&s_type=i&s_search=' + isbn, 'Internetbokhandeln', 'burro_ibse' )); + table.appendChild( add_site( 'http://hip.bibl.liu.se/ipac20/ipac.jsp?menu=search&index=ISBN&term=' + isbn, 'LiU Library', 'burro_liubibl' )); table.appendChild( add_site("http://www.powells.com/cgi-bin/biblio?isbn=" + isbn, "Powell's Books", "burro_powell")); box.appendChild(table); - box.onclick = function() { + box.addEventListener( 'click', function() { var carrot = document.getElementById('hide_show_carrot'); if (this.style.height != "auto") { if (this.style.height == "15px") run_queries( isbn ); // height is 15 only first time you expand, thus only 1 query @@ -252,26 +360,64 @@ carrot["src"] = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAALCAYAAACprHcmAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH1QQYCR020Q08hgAAAB10RVh0Q29tbWVudABDcmVhdGVkIHdpdGggVGhlIEdJTVDvZCVuAAAAiklEQVQY07XPIQoCURSF4e8NAzYxGicNuAa1WlyCO3AlZnfiNgwahQFxikkcBIsGfaZpzgODJ/4c/nMvPyR8g7EsephgH6q6aXnWIelhjkUsi0EL88TqFUfMYlnscMoS5wUccMYS4yxhfuGNPho88oQ5xxQjrHHpKkcMccMqVPU99eATG2zb4n/zAS4OHrV1hIB/AAAAAElFTkSuQmCC"; this.style.height = "14px"; } - }; + }, true); document.getElementsByTagName("body")[0].appendChild(box); } -if (document.location.href.match('amazon.com') && !document.location.href.match('rate-this')) { +if (document.location.hostname.match('amazon.com') && !document.location.href.match('rate-this')) { isbn = checkISBN(document.location.href.match(/\/([0-9X]{10})(\/|\?|$)/)[1]); if (isbn) burro( 'amazon', isbn ); } -if (document.location.href.match('barnesandnoble.com')) { +if (document.location.hostname.match('barnesandnoble.com')) { isbn = checkISBN( document.location.href.match(/[iI][sS][Bb][Nn]=([0-9X]{10})(\&|\?|$)/)[1] ); if (isbn) burro( 'bn', isbn ); } -if (document.location.href.match('buy.com')) { +if (document.location.hostname.match('bokus.com')) { + isbn = checkISBN( document.location.href.match(/\/([0-9X]{10})\.html(\?|$)/)[1] ); + if (isbn) burro( 'bokus', isbn ); +} + +if (document.location.hostname.match('internetbokhandeln.se')) { + isbn = checkISBN( document.location.href.match(/\/bok([0-9X]{10})\.html(\?|$)/)[1] ); + if (isbn) burro( 'ibse', isbn ); +} + +if (document.location.hostname.match('adlibris.se')) { + isbn = checkISBN( document.location.search.match(/[?&]isbn=([0-9X]{10})(&|$)/i)[1] ); + if (isbn) burro( 'alse', isbn ); +} + +if (document.location.hostname.match('akademibokhandeln.se')) { + var tds = document.getElementsByTagName( 'td' ), i; + for( i=0; i