Skip to content

Instantly share code, notes, and snippets.

@rmateu
Forked from mokkunp/bookmarklet.md
Last active September 10, 2018 11:06
Show Gist options
  • Save rmateu/596ffdfc183a1f7cf58f3d5d9bbc16ae to your computer and use it in GitHub Desktop.
Save rmateu/596ffdfc183a1f7cf58f3d5d9bbc16ae to your computer and use it in GitHub Desktop.
Amazon Books Title, author and image bookmarklet.
var title = document.getElementById("ebooksProductTitle");
if (title == null) {
title = document.getElementById("productTitle")
};
title = title.innerText;
var imageUrl = document.getElementById("ebooksImgBlkFront");
if (imageUrl == null) {
imageUrl = document.getElementById("imgBlkFront")
};
imageUrl = imageUrl.src;
var author = document.getElementById("byline").innerText;
var asinURL = location.origin + location.pathname.match(/\/dp\/[^/]+/)[0];
// location.href = "https://scrapbox.io/xxxxxxxxxx/" + encodeURIComponent(title) + "?body=" + encodeURIComponent(author + "\n[" + imageUrl + "]\n\n" + location.origin + location.pathname.match(/\/dp\/[^/]+/)[0] + "\n\n#book")
prompt("Enter Ctrl+C to copy this book:", "["+ title + "](" + asinURL + ")" + " " + author + "\n\n" + "![" + title + "](" + imageUrl + ")" );
var title = document.getElementById("ebooksProductTitle");
if (title == null) {
title = document.getElementById("productTitle")
};
title = title.innerText;
var imageUrl = document.getElementById("ebooksImgBlkFront");
if (imageUrl == null) {
imageUrl = document.getElementById("imgBlkFront")
};
imageUrl = imageUrl.src;
var author = document.getElementById("byline").innerText;
// location.href = "https://scrapbox.io/xxxxxxxxxx/" + encodeURIComponent(title) + "?body=" + encodeURIComponent(author + "\n[" + imageUrl + "]\n\n" + location.origin + location.pathname.match(/\/dp\/[^/]+/)[0] + "\n\n#book")
// prompt("Enter Ctrl+C to copy this book:", title + " " + author + "\n\n" + imageUrl +
// "\n\n" + location.origin + location.pathname.match(/\/dp\/[^/]+/)[0]);
javascript: (function(win, name, desc) {
win.open('https://trello.com/add-card' + '?source=' + win.location.host + '&mode=popup' + '&url=' + encodeURIComponent(win.location.href) + (name ? '&name=' + encodeURIComponent(name) : '') + (desc ? '&desc=' + encodeURIComponent('## » [' + document.title + '](' + location + ')\n\n>' + desc) : '') + '&idList=59089b596bfcf40dcbd96932', 'add-trello-card', 'width=500,height=600,left=' + (win.screenX + (win.outerWidth - 500) / 2) + ',top=' + (win.screenY + (win.outerHeight - 740) / 2))
})(window, document.title, getSelection ? getSelection().toString() : '')
// win.open('https://trello.com/add-card'
// + '?source=' + win.location.host
// + '&mode=popup'
// + '&url=' + encodeURIComponent(win.location.href)
// + (name ? '&name=' + encodeURIComponent(name) : '')
// + (desc ? '&desc=' + encodeURIComponent(desc) : '')
// '&idList=5767ff7f834e691d5cbf0370', 'add-trello-card', 'width=500,height=600,left=' + (win.screenX + (win.outerWidth - 500) / 2) + ',top=' + (win.screenY + (win.outerHeight - 740) / 2))
var title = document.getElementById("ebooksProductTitle");
if (title == null) {
title = document.getElementById("productTitle")
};
title = title.innerText;
var imageUrl = document.getElementById("ebooksImgBlkFront");
if (imageUrl == null) {
imageUrl = document.getElementById("imgBlkFront")
};
imageUrl = imageUrl.src;
var author = document.getElementById("byline").innerText;
// location.href = "https://scrapbox.io/xxxxxxxxxx/" + encodeURIComponent(title) + "?body=" + encodeURIComponent(author + "\n[" + imageUrl + "]\n\n" + location.origin + location.pathname.match(/\/dp\/[^/]+/)[0] + "\n\n#book")
prompt("Enter Ctrl+C to copy this book:", title + " " + author + "\n\n" + imageUrl +
"\n\n" + location.origin + location.pathname.match(/\/dp\/[^/]+/)[0]);
// Test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment