Created
June 3, 2019 14:00
-
-
Save 3110/2c26ce40c831e9082e0c2b67ad817e11 to your computer and use it in GitHub Desktop.
表示しているページのScrapbox用のリンクを表示する。Amazonの場合は書影とURLのリンクにする。
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 promptTitle = 'ScrapboxLink'; | |
let prompt; | |
if (window.location.href.startsWith('https://www.amazon.co.jp')) { | |
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; | |
} | |
prompt = [image.src, 'https://amazon.jp/dp/' + asin.value]; | |
} else { | |
prompt = [document.title.replace(/\s*[\[\]]\s*/g,' '), location.href]; | |
} | |
window.prompt(promptTitle, '[' + prompt.join(' ') + ']'); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment