AmazonからScrapboxに取り込むJavaScript(改良版)
末尾の「購入日:」は取り込んだ日になる。
javascript:(function(){var p=document.getElementById("productTitle");if(!p)var p=document.getElementById("ebooksProductTitle");var d=document.getElementById("productDescription");if(!d){var subdoc=document.getElementById("product-description-iframe").contentWindow.document;var d=subdoc.getElementById("productDescription");}var d1=d.getElementsByTagName("p")0;if(!d1)var d1=d.getElementsByClassName("productDescriptionWrapper")0;var d2=d1.innerText.replace(/\n/g,'\n>');var title=window.prompt('Scrap "Amazon" to your scrapbox.', p.innerHTML);if(!title)return;title='%E3%80%8E'+title+'%E3%80%8F';var imagecontainer=document.getElementById("imageBlockContainer");if(!imagecontainer) var imagecontainer = document.getElementById("ebooksImageBlockContainer");let image=imagecontainer.getElementsByTagName("img")0;let imageurl=image.getAttribute("src");let pub=[];var c=document.getElementsByClassName('author');for (g=0;g<c.length;g++){var at=cg.innerText.replace(/,/,'');var pu=at.match(/\(.+\)/);var ct=at.replace(/\(.+\)/,'').replace(/ /g,'');pub.push(pu+' + ct + '');}var dt=new Date();var y = dt.getFullYear();var m = ("00" + (dt.getMonth()+1)).slice(-2);var d = ("00" + dt.getDate()).slice(-2);var today = y + "/" + m + "/" + d;var lines=''+title+' '+window.location.href+'/cl007-22\n'+''+imageurl+' '+window.location.href+'/cl007-22\n'+pub.join(' ')+'\n>'+d2+'\n#BOOKS\n#読んでいる本\n購入日:'+today;var%20body=encodeURIComponent(lines);window.open('https://scrapbox.io/cyblog/'+encodeURIComponent(title.trim())+'?body='+body)})(); 修正箇所
cl007-22 → アソシエイトID(2箇所)
#BOOKS\n#読んでいる本 → 任意のタグ(この行の#は全角にしている)
cyblog → プロジェクトID