generated at
amazonaffilink
修正履歴
2023/10/31
画像が拾えなくなっていたので修正
script.js
var asin = document.getElementById('ASIN');//ASINの処理 if(asin){ var url = "http://www.amazon.co.jp/exec/obidos/ASIN/" + asin.value + "/rashita1000-22/ref=nosim/" } else{ var asin = document.getElementsByName('ASIN.0')[0]; var url = "http://www.amazon.co.jp/exec/obidos/ASIN/" + asin.value + '/rashita1000-22/ref=nosim/' } var image=document.getElementById("landingImage");//書影の処理 if (!image) var image = document.getElementById("ebooksImgBlkFront"); var imageurl = image.getAttribute("src"); var htmltag = '<p style="text-align: center;"><a href="' + url + '" target="_blank" rel="noopener" name="amazletlink"><img class="aligncenter" style="border: none;" src="' + imageurl + '" alt="" /></a></p>'; var middlehtmltag = htmltag.replace( '.jpg', '._SY346_.jpg' ); var smallhtmltag = htmltag.replace( '.jpg', '._SL160_.jpg' ); nwin = window.open("", "Newwindow","width=400,height=800"); nwin.document.open(); nwin.document.write("<HTML><HEAD>"); nwin.document.write("<TITLE>New one</TITLE>"); nwin.document.write('<BODY>'); nwin.document.write(middlehtmltag); nwin.document.write('<textarea onclick="this.select();" rows="4" cols="40">'); nwin.document.write(middlehtmltag); nwin.document.write('</textarea>'); nwin.document.write(smallhtmltag); nwin.document.write('<textarea onclick="this.select();" rows="4" cols="40">'); nwin.document.write(smallhtmltag); nwin.document.write('</textarea></BODY></HTML>'); nwin.document.close(); nwin.window.focus();


ブックマークレットからこのページのコードにアクセスする記述

どんなリンクを作っているか?
どうやって画像を引っ張ってきているか?

amazletで作成されるコード
><p style="text-align: center;"><a href="http://www.amazon.co.jp/exec/obidos/ASIN/B081KZC789/rashita1000-22/ref=nosim/" target="_blank" rel="noopener" name="amazletlink"><img class="aligncenter" style="border: none;" src="https://images-fe.ssl-images-amazon.com/images/I/41p1H60XjHL._SL160_.jpg" alt="書くための名前のない技術 case 2 Marieさん" /></a>

URL
ASINが分かればいい。
<input type="hidden" name="ASIN.0" value="B081RBRMFB">に入っている。
image
APIを叩かないとなかなかやっかい
class a-dynamic-image frontImage
id ebooksImgBlkFront
紙の本では  id="imgBlkFront"
class="a-dynamic-image image-stretch-vertical frontImage"

上の二つを切り分けられるなら、APIを叩かなくても大丈夫?
どうせAmazonページからひらくわけだし。

41u…みたいなものがわかれば、サイズは自由に作れる(はず)

2019/11/30
とりあえず動いてはいるが、画像のサイズが大きいかもしれない。
._SL160_. を拡張子の前につければいい。
テキストエリアの処理
文字列の置換
basicscript.js
var asin = document.getElementById('ASIN');// if(asin){ var url = "http://www.amazon.co.jp/exec/obidos/ASIN/" + asin.value + "/rashita1000-22/ref=nosim/" } else{ var asin = document.getElementsByName('ASIN.0')[0]; var url = "http://www.amazon.co.jp/exec/obidos/ASIN/" + asin.value + "/rashita1000-22/ref=nosim/" } var imagecontainer=document.getElementById("imageBlockContainer");//書影の処理 if (!imagecontainer) var imagecontainer = document.getElementById("ebooksImageBlockContainer"); var image = imagecontainer.getElementsByTagName("img")[0]; var imageurl = image.getAttribute("src"); var htmltag = '<p style="text-align: center;"><a href="' + url + 'target="_blank" rel="noopener" name="amazletlink"><img class="aligncenter" style="border: none;" src="' + imageurl + '" alt="" /></a>'; var smallhtmltag = htmltag.replace( '.jpg', '._SL160_.jpg' ); nwin = window.open("", "Newwindow","width=400,height=600"); nwin.document.open(); nwin.document.write("<HTML><HEAD>"); nwin.document.write("<TITLE>New one</TITLE>"); nwin.document.write('<BODY>'); nwin.document.write(htmltag); nwin.document.write('<textarea onclick="this.select();" rows="4" cols="40">'); nwin.document.write(htmltag); nwin.document.write('</textarea><textarea onclick="this.select();" rows="4" cols="40">'); nwin.document.write(smallhtmltag); nwin.document.write('</textarea></BODY></HTML>'); nwin.document.close();

2020/5/1
書影の取り込みがうまくいかない場合があるので、それを修正。