bookmarklet
(2019年5月4日)公式のShare ブックマークレットが使えなくなったようなので、簡単に自作。
javascript:(function(){
window.open(
"https://twitter.com/intent/tweet?url=" + encodeURIComponent(location.href) + "&text=" + encodeURIComponent(document.title),
"_blank",
"width=600,height=450");
})()
TwitterShare
選択したテキストをリンク文字とタイトルにしたリンクを作る
自分がよくやる処理なので自動化したいと思いまして。(2008年9月21日)
(2009年2月17日)Operaで動かなくなったけど、opera exで充分になったので放置状態。
(2021年12月21日)また使っています。ちゃんと動いています。直接ブックマークに登録できればいいんだけど、ブラウザがそういう操作をサポートしていなくて、手で入力して登録する必要がありました。
(2021年12月22日)変数のフォーカスを小さくしました。
選択したテキストをリンク文字とタイトルにしたリンクを作る
javascript:(function(d,b,w,dt){
b='';
if(d.getSelection){b=document.getSelection()};
if(d.selection){b=d.selection.createRange().text};
if(b==''){b=d.title};
if(b==''){void(b=prompt('リンクのタイトル',''))};
if(b!=null){
dt=new Date();
w=open('','w'+dt.getTime(),'width=400,height=400');
with(w.document){
write('<a href="'+encodeURI(d.location.href)+'" title="'+b+'">'+b+
'</a><br /><center><form name="BmyUut42SJU3"><textarea rows=13 cols=40 wrap name="BmyUuz2qX92PpdC"><a href="'+encodeURI(d.location.href)+
'" title="'+b+'">'+b+'</a></textarea>');
BmyUut42SJU3.BmyUuz2qX92PpdC.focus();
BmyUut42SJU3.BmyUuz2qX92PpdC.select();
void(close())
}
}else{void(null)}
})(document)
ソースの方は適宜改行を入れています。
あと、厳密にはフレームだった場合の選択文字列とかブラウザ間の差異なども吸収する必要があります。とりあえず自分としてはOperaで動けばいいやって感じの検証しかしていません。document.execCommand("copy");
も入れたいところだけど自分の環境ではうまく動かなかったのでここでは入れてません。欲しい人は自分で加えてください。
CreateBlockquote
上と同じものの blockquote版
javascript:(function(d,b,t,w,dt){
b=t='';
t=d.title;
if(d.getSelection){b=d.getSelection()};
if(d.selection){b=d.selection.createRange().text};
if(b==''){b=d.title};
if(b==''){void(b=prompt('引用文',''))};
if(b!=null){
dt=new Date();
w=open('','w'+dt.getTime(),'width=400,height=300');
with(w.document){
write('<blockquote cite="'+encodeURI(document.location.href)+'" title="'+t+'">'+b+
'</blockquote><br /><center><form name="BmyUut42SJU3"><textarea rows=13 cols=40 wrap name="BmyUuz2qX92PpdC"><blockquote cite="'+encodeURI(document.location.href)+
'" title="'+t+'">'+b+'</blockquote></textarea>');
BmyUut42SJU3.BmyUuz2qX92PpdC.focus();
BmyUut42SJU3.BmyUuz2qX92PpdC.select();
void(close())
}
}else{void(null)}
})(document)
オートコンプリート有効化
javascript:(function(d){
d.querySelectorAll('[autocomplete="off"]').forEach(function(e){
e.autocomplete='on';
})
})(document);