Amazon to Google Book Search Linky (English Ver. GOOG Color)

By Koumei_S Last update Jan 26, 2009 — Installed 412 times. Daily Installs: 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 2, 0

There are 2 previous versions of this script.

// ==UserScript==
// @name          Amazon to Google Book Search Linky (English Ver. GOOG Color)
// @namespace     http://d.hatena.ne.jp/Koumei_S/
// @description	  generates link from Amazon to Google Book Search
// @include       http://*.amazon.tld/*
// @version       1.1
// ==/UserScript==

libsearch();

function libsearch() {
	var asin10 = document.location.href.match(/\/(\d{9}[\d|X])(\/|$)/)[1];
	//var href = document.location.href;
	//var index = href.indexOf('product');
	//var asin10 = href.substring(index+8,index+18);
	if (asin10){
		// var isbn = mainmatch[1];
		var header = document.evaluate("id('priceBlock')", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
		if (location.host.match(/^astore/)){
			header = document.getElementsByTagName('h2')[0];
		}
		if (header) {
			var spl_link = document.createElement('a');
			spl_link.setAttribute('href', 'http://books.google.com/books?q=isbn:' + asin10);
			spl_link.setAttribute('title', 'To Google Book Search');
			spl_link.setAttribute('target', '_blank');
			spl_link.innerHTML = '</br><span style=\"font-size:90%; background-color:#ffcccc;\">>> <span style=\"color:#1849B5\">G</span><span style=\"color:#C61800\">o</span><span style=\"color:#FFEF08\">o</span><span style=\"color:#1849B5\">g</span><span style=\"color:#39BA42\">l</span><span style=\"color:#C61800\">e</span> Book Search!</span>';
			header.parentNode.insertBefore(spl_link, header.nextSibling);
		}
	}
}