Created
May 11, 2010 12:38
-
-
Save norio-nomura/397255 to your computer and use it in GitHub Desktop.
j.mp で短縮した url を渡して Echofon を呼び出す。login と apiKey を埋め込んでください。
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:var c='login=YOUR_LOGIN_HERE&apiKey=YOUR_API_KEY_HERE',d=document,w=window,enc=encodeURIComponent,j=w.getSelection,k=d.getSelection,x=d.selection,s=(j?j():(k?k():(x?x.createRange().text:0))),s2=((s.toString()=='')?s:('"'+enc(s)+'" ')),l=d.location,e=d.createElement('script'); | |
if(typeof(BitlyCB)=='undefined')var BitlyCB={}; | |
BitlyCB.shortenResponse=function(r){ | |
if (r.status_code==200) { | |
p=enc(d.title)+' '+s2+enc(r.data.url),u='echofon:'+p; | |
try{if(!/^(.*\.)?tumblrzzz[^.]*$/.test(l.host))throw(0);tstbklt();} | |
catch(z){ | |
a=function(){w.location=u;}; | |
if(/Firefox/.test(navigator.userAgent))setTimeout(a,0); | |
else a(); | |
}; | |
} | |
}; | |
e.setAttribute('language','javascript'); | |
e.setAttribute('src','http://api.bit.ly/v3/shorten?callback=BitlyCB.shortenResponse&domain=j.mp&'+c+'&longUrl='+enc(l.href)); | |
d.body.appendChild(e); | |
void(0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://api.bit.ly/v3/shorten を使う様に変えた。
Safari 5.0.1, Chrome 6.0.472.11, FireFox 4.0b2 で動作確認した。