Skip to content

Instantly share code, notes, and snippets.

@masaakif
Created December 16, 2008 06:45
Show Gist options
  • Save masaakif/36358 to your computer and use it in GitHub Desktop.
Save masaakif/36358 to your computer and use it in GitHub Desktop.
Amazon Chuo Ward Library Linky
// ==UserScript==
// @name Amazon Chuo Ward Library Linky
// @namespace http://gist.github.com/36358
// @description Chuo Ward Library Lookup from Amazon book listings.
// @include http://*.amazon.*
// ==/UserScript==
// Version 20090105
var DEBUG=true;
libsearch();
function libsearch() {
var val = document.getElementById("ASIN").value;
if (val!=''){
asin = val;
var header = document.evaluate("//div[@class='buying']/a", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
if (header) {
var f = document.createElement('form');
f.setAttribute('method', 'POST');
f.setAttribute('action', 'http://www.library.city.chuo.tokyo.jp/clis/search');
f.setAttribute('id', 'frmGMChuoLib');
f.setAttribute('onsubmit', 'return false;');
f.setAttribute('target', '_blank');
var fi = document.createElement('input');
fi.setAttribute('type', 'hidden');
fi.setAttribute('name', 'ISBN');
fi.setAttribute('value', asin);
f.appendChild(fi);
var spl_link = document.createElement('a');
spl_link.setAttribute('href', "javascript:frmGMChuoLib.submit();");
spl_link.setAttribute('title', 'To Chuo Ward City Library');
spl_link.innerHTML = '<span style=\"font-size:90%; background-color:#ffffcc;\">»中央区立図書館検索<br></span>';
f.appendChild(spl_link);
header.parentNode.insertBefore(f, header);
}
}
}
function debug() {
if ( typeof DEBUG != 'undefined' && DEBUG ) {
console.log.apply(this, arguments)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment