Amazonから本のページをつくるブックマークレット
簡単便利
これをclaudeに投げて1行にしてもらった 多分動く
mouii のところを自分のproject URLに変えること
code:コピペしてブックマークにいれてamazonの本のページで開く
javascript:(function(){var p=document.getElementById("productTitle");if(!p)var p=document.getElementById("ebooksProductTitle");var title=window.prompt('Scrap "Amazon" to your scrapbox.',p.innerText.trim());if(!title)return;var asin=document.getElementById('ASIN');if(asin){var a='ISBN:'+asin.value;}else{var asin=document.getElementsByName('ASIN.0')0,a='ASIN:'+asin.value;}var detail=document.getElementById('detailBullets_feature_div');if(!detail){var subdoc=document.querySelector("#product-description-iframe").contentDocument;var detail=subdoc.getElementById("productDetailsTable");}var detailtext=detail.innerText;var pubdata=detailtext.match(/(%E5%87%BA%E7%89%88%E7%A4%BE%20:%20.+)%20(\(.+\))/);if(pubdata){pubdata1=pubdata1.replace(/:%20/,':[');pubdata1=(pubdata1.match(/;/)?pubdata1.replace(/;/,'];'):pubdata1.trim()+']');pubdata2=pubdata2.replace(/\((\d+\/\d+)\//,'($1/')+'%20';}else{var pubdata='','','';}const isbookDesc=document.getElementById("bookDescription_feature_div");if(isbookDesc){if(isbookDesc.innerText==""){const eDiv=document.getElementById("editorialReviews_feature_div");if(eDiv)d1=eDiv.innerText.replace(/\n/g,"\n>")}else{var d1=isbookDesc.innerText.replace(/\n/g,"\n>").replace("%E7%B6%9A%E3%81%8D%E3%82%92%E8%AA%AD%E3%82%80","")}}else{const probookDesc=document.getElementById("productDescription_feature_div");if(probookDesc){var decsdocP=document.getElementsByClassName("pInfoTabCExpander-content");var decsdoc=decsdocP0;var d1=decsdoc.innerText.replace(/\n/g,"\n>")}}var image=document.getElementById("landingImage");if(!image)var image=document.getElementById("ebooksImgBlkFront");var imageurl=image.getAttribute("src");var pub=[];var c=document.getElementsByClassName('author');for(g=0;g<c.length;g++){var at=cg.innerText.replace(/\r?\n/g,'').replace(/,/,'');var pu=at.match(/\(.+\)/);var ct=at.replace(/\(.+\)/,'').replace(/%20/g,'');pub.push(pu+'%20'+ct.trim()+'');}var lines=''+imageurl+'%20'+window.location.href+'\n'+pub.join('%20')+'\n'+pubdata1+pubdata2+a+'\n>'+d1+'\n#book\n';var body=encodeURIComponent(lines);window.location.href='https://scrapbox.io/mouii/'+encodeURIComponent(title.trim())+'?body='+body})();