Created
April 24, 2019 15:42
-
-
Save 3110/81f78d6e3a89e12175439b1eeecb1fac to your computer and use it in GitHub Desktop.
アマゾンの書籍情報を元にScrapboxページを作成する。
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
javascript:(function() { | |
const project = 'https://scrapbox.io/[プロジェクト名]/'; /* 自分のプロジェクト名に変更 */ | |
if (!window.location.href.startsWith('https://www.amazon.co.jp')) { | |
return; | |
} | |
const isKindle = window.location.href.indexOf('-ebook') > 0; | |
const title = document.body.querySelector("span[id='productTitle'], span[id='ebooksProductTitle']"); | |
if (title === null) { | |
return; | |
} | |
const asin = document.body.querySelector("input[name='ASIN'], input[name='ASIN.0']"); | |
if (asin === null) { | |
return; | |
} | |
const image = document.body.querySelector("img[id='imgBlkFront'], img[id='ebooksImgBlkFront']"); | |
if (image === null) { | |
return; | |
} | |
const titleStr = encodeURIComponent(title.textContent.trim()); | |
const bodyStr = encodeURIComponent('[' + image.src + ' ' + 'https://amazon.jp/dp/' + asin.value + ']' | |
+ "\n" | |
+ "#書籍" | |
+ (isKindle ? " #kindle" : "")); | |
window.open(project + titleStr +'?body=' + bodyStr); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment