Androidアプリをブログ(WordPress)上で紹介するBookmarklet(新版)
以前作ったBookmarkletがIE11では動くけど、Firefox(27.0.1)では動かない。ブックマークレット内のjavascriptの扱いが変わったのか前のスクリプトでは通らなくなりましたので変更しました。 たとえば以前は
var%20a=10;
a=10;
javascript:(function(){url=location;t=document.getElementsByClassName("document-title");if(t!=undefined){s=String.fromCharCode(0x20);title=t[0].textContent;imgsrc=document.getElementsByClassName("cover-image")[0].src;t=document.getElementsByClassName("document-subtitle")[0];authorlink=t.href;author=t.textContent;dat=document.getElementsByClassName("document-subtitle")[1].textContent;t=document.getElementsByClassName("document-subtitle")[2];category=t.textContent;catlink=t.href;h='<div'+s+'class="androidapp"><a'+s+'href="'+url+'"'+s+'target="_blank"'+s+'rel="nofollow"><img'+s+'class="alignleft"'+s+'src="'+imgsrc+'"'+s+'width="128"></a><a'+s+'href="'+url+'"'+s+'target="_blank"'+s+'rel="nofollow"><span'+s+'class="androidapp-title">'+title+'</span></a><br><a'+s+'href="'+authorlink+'"'+s+'target="_blank"'+s+'rel="nofollow">'+author+'</a><span'+s+'class="androidapp-author">'+dat+'</span><br><a'+s+'href="'+catlink+'"'+s+'target="_blank"'+s+'rel="nofollow"><span'+s+'class="androidapp-category">'+category+'</span></a><br><a'+s+'href="'+url+'"'+s+'target="_blank"'+s+'rel="nofollow"><img'+s+'alt="Android'+s+'app'+s+'on'+s+'Google'+s+'Play"'+s+'src="https://developer.android.com/images/brand/ja_app_rgb_wo_45.png"/></a><br'+s+'style="clear:'+s+'both;"></div>';alert(h);}else{alert("Can't'+s+'analyze'+s+'app'+s+'data'+s+'in'+s+'html");}})();
javascript:
(function(){
url=location;
t=document.getElementsByClassName("document-title");
if(t!=undefined){
s=String.fromCharCode(0x20);
title=t[0].textContent;
imgsrc=document.getElementsByClassName("cover-image")[0].src;
t=document.getElementsByClassName("document-subtitle")[0];
authorlink=t.href;
author=t.textContent;
dat=document.getElementsByClassName("document-subtitle")[1].textContent;
t=document.getElementsByClassName("document-subtitle")[2];
category=t.textContent;
catlink=t.href;
h='<div'+s+'class="androidapp"><a'+s+'href="'+url+'"'+s+'target="_blank"'+s+'rel="nofollow"><img'+s+'class="alignleft"'+s+'src="'+imgsrc+'"'+s+'width="128"></a><a'+s+'href="'+url+'"'+s+'target="_blank"'+s+'rel="nofollow"><span'+s+'class="androidapp-title">'+title+'</span></a><br><a'+s+'href="'+authorlink+'"'+s+'target="_blank"'+s+'rel="nofollow">'+author+'</a><span'+s+'class="androidapp-author">'+dat+'</span><br><a'+s+'href="'+catlink+'"'+s+'target="_blank"'+s+'rel="nofollow"><span'+s+'class="androidapp-category">'+category+'</span></a><br><a'+s+'href="'+url+'"'+s+'target="_blank"'+s+'rel="nofollow"><img'+s+'alt="Android'+s+'app'+s+'on'+s+'Google'+s+'Play"'+s+'src="https://developer.android.com/images/brand/ja_app_rgb_wo_45.png"/></a><br'+s+'style="clear:'+s+'both;"></div>';
alert(h);
}
else{
alert("Can't'+s+'analyze'+s+'app'+s+'data'+s+'in'+s+'html");
}
}
)();