Created
November 30, 2010 11:22
-
-
Save hyagni/721543 to your computer and use it in GitHub Desktop.
On amazon pages, copy to clipboard the bookinfo (ASIN, author, title, URL) with C-cC-p
This file contains 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
key.setViewKey(['C-c', 'C-p'], function(ev){ | |
var loc = getBrowser().contentDocument.URL; | |
var doc = frame = document.commandDispatcher.focusedWindow.document | |
|| gBrowser.contentWindow.document; | |
if(loc.match(/www\.amazon\./)){ | |
asin = loc.split("/")[5]; | |
r = doc.evaluate("//div[@class='buying']",doc,null,XPathResult.FIRST_ORDERED_NODE_TYPE, null); | |
list = r.singleNodeValue.textContent.split("\n"); | |
var info = Array(); | |
for(i=0; i<list.length; i++ ){ | |
list[i] = list[i].trim(); | |
if(list[i] != "") | |
info[info.length] = list[i]; | |
} | |
var title = ""; | |
a = info[0].split(' '); | |
for(i=0; i<a.length; i++){ | |
if(a[i][0] != "[") title += a[i]; | |
else break; | |
} | |
var output = info[1] + " \"" + title + "\" " + asin + "[[" + loc + "]]"; | |
command.setClipboardText(output); | |
} | |
}, "Get book information", false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment