Created
March 22, 2012 05:11
-
-
Save masaakif/2156262 to your computer and use it in GitHub Desktop.
Add Calil link on Amazon page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Amazon Calil | |
| // @namespace http://gist.github.com/2156262 | |
| // @description Show calil page from Amazon book listing | |
| // @include http://*.amazon.* | |
| // ==/UserScript== | |
| var DEBUG=true; | |
| showCalil(); | |
| function showCalil() { | |
| var val = document.getElementById("ASIN").value; | |
| if (val != '') { | |
| var header = document.evaluate("//div[@class='buying']/a", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; | |
| if (header == undefined) { | |
| header = document.evaluate("//div[@class='buying']//a[contains(@id, 'contribut')]", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; | |
| } | |
| if (header) { | |
| var link = document.createElement('a'); | |
| link.setAttribute('href', 'http://calil.jp/book/' + val); | |
| link.setAttribute('target', '_blank'); | |
| link.innerHTML = '<span style=\"font-size:90%; background-color:#ffffcc;\">»Open Calil<br></span>'; | |
| header.parentNode.insertBefore(link, 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