「Web検索」にエディタ機能を付けてみた DarkRoom(Javascript版)

恒例のアレです。


「Web検索」で検索してもアプリの「Web検索」にヒットしない WebScript
これがステルス・マーケットなのか。見つからんじゃないか。とんでもない独自機能を実装しました。ブックマークレットです。「javascript:うんぬん、ってヤツ?」というのは、半分正しく半分間違っている...
Web検索 - 再訪問のしやすいウェブブラウザ 1.1.0
分類: 辞書/辞典/その他
価格: 無料 (tadashi atoji)

Javascriptが走るなら、やるしかない。ブラウザをエディタにしてしまうブックマークレット。「Web検索」を触っているうちに血が沸騰しました。ここまでブックマークレットを優先するなら、普通のブラウザに出来ないことをさせたい。これをインストール。
登録リンクはこちら→ http://tinyurl.com/k6ny439



もちろん韋駄天カーソル。盤面を左右に撫でればカーソルが走る。



二本指でスライドすれば範囲選択になります。



そして、キーボード左上の「< >」が Undo/Redo 。時間移動します。



フォントをカスタマイズ。下記のように、Javascript:の次に fontsize, color, bgcolor の変数があります。この三つを書き換え、ご自分の環境に合わせてください。

javascript:fontsize="16px";color="lime";bgcolor="black";scr="<meta name=viewport content=initial-scale=1,user-scalable=no><title>DarkRoom</title><body style=background:"+bgcolor+";margin:0;><textarea current=text id=text style=\"color:"+color+"; background:"+bgcolor+";font-size:"+fontsize+";width:100%25;height:1000%25;border:0;\" onBlur=saveText() tabindex=2></textarea><input style=border:0;width:70;background:"+bgcolor+"; onFocus=document.execCommand('undo') placeholder=取り消す tabindex=1><input style=border:0;width:70;background:"+bgcolor+"; onFocus=document.execCommand('redo') placeholder=やり直す tabindex=3><script>var p,mode;text.value=localStorage.text || \"\";text.selectionStart=localStorage.text.loc || 0;text.ontouchstart=Start;text.ontouchmove=Move;text.focus();function Move(e){x=e.touches[0].pageX;if(x-p>4){text.setSelectionRange(text.selectionStart+mode,text.selectionEnd+1);p=x;}if(p-x>4){text.setSelectionRange(text.selectionStart-mode,text.selectionEnd-1);p=x;}}function Start(e){p=e.touches[0].pageX;mode=(text.selectionStart == text.selectionEnd);if(e.touches.length==2) mode=0;}function saveText(){localStorage.text=text.value;localStorage.text.loc=text.selectionStart;if(text.selectionStart==text.selectionEnd){list=text.value.split(\"\\n\");for(i=n=0;i<list.length;i++){n+=list[i].length+1;if(n>text.selectionStart) break;}text.current=list[i];}else{text.current=text.value.substr(text.selectionStart,text.selectionEnd-text.selectionStart);}}</script></body>";document.write(scr);


この DarkRoom は localStorage を使っているのでテキストが消えません。同じサイトで起動すれば以前のテキストが復活します。ゴミが溜まるとも言える。でも、サイトについての感想をメモ書きできて、意外と面白い効能があるので残しておきます。
また、text.value と text.current の二つの変数が使えます。他のブックマークレットに全文(text.value)を渡したり、カーソル行(text.current)を渡したりできる。エディタっぽいでしょ? これについてはまた、日を改めて記事に仕上げたいと思います。

  • WebエディタDarkRoomで使えるブックマークレット(Web検索用)