書いてみた | |
うそです!!
もう既にこういうプラグインはあるかもしれないけど・・・
http://github.com/voidy21/dotfiles/raw/master/.vimperator/plugin/gcal.js
:gcal 17:00-19:00 図書館へ行く
:gcal 8/20 14:00 動物園
:gcal 8/25-8/31 夏期休暇
カレンダーを指定する場合は-calendarオプションを使うと指定できます(補完を効かせないと使いづらいかも・・・)
:gcal
デフォルトでは、今日の予定と2週間後までの予定を表示します
あと、:gcal -date 2010/8/17 とかすると2010/8/17の予定だけを表示します
書いてみた | |
:js commandline.echo(template.commandOutput(<><img src={tabs.getTab().__thumbnail.toDataURL()}/></>),null,commandline.FORCE_SINGLELINE)
_libly.jsが入っていると割と格好よくechoされる
commands.addUserCommand(
["thumbnail"],
"View Thumbnails",
function(args){
if(args != "") {
liberator.open(args.string);
}
},
{
count: false,
completer: function(context, args) {
let filter = context.filter;
context.keys = {title: 'title', thumbnail: 'thumbnail', url: 'url', text:'text'};
context.process = [templateThumbnail,function(obj){return obj.url}];
context.title = ['Buffer','URL'];
context.completions = generateCandidates();
}
},
true
);
function templateThumbnail(obj) {
return <>
<img src={obj.thumbnail}/>{obj.title}
</>;
}
function generateCandidates() {
let allTabInfo = [];
let index = 0;
for each ( [,tab] in tabs.browsers ) {
let url = tab.currentURI.spec;
let title = tab.contentTitle;
let getTab = tabs.getTab(index++);
let thumbnail = ('__thumbnail' in getTab) ? getTab.__thumbnail.toDataURL() : "";
let tabInfo = {
"text": index + ":",
"url" : url,
"thumbnail" : thumbnail,
"title" : title,
}
allTabInfo = allTabInfo.concat(tabInfo);
}
return allTabInfo;
}
caisuiワンライナーのほうは、getTab()→getTab(数字) ではないでしょうか?
エラーでたので報告です。
voidy21> id:caisui
コメントありがとうございます!
>> ワンライナーのほうは、getTab()→getTab(数字) ではないでしょうか?
一応、ソースを見る限り、数字を省略しても大丈夫なはずなんですが・・・
http://code.google.com/p/vimperator-labs/source/browse/common/content/tabs.js?r=7c7331c0ad121902689d067449dd091e45c41f7c#182
おそらくエラーはタブを開いたばかりで__thumbnailが作られていなかったからではないかと思いますが、間違っていたら申し訳ないです
caisui問題点の2番目が 問題でした。
何も考えずに、開いたtabで ワンライナー走らせてました。orz
お騒がせしました。
書いてみた | |
:js for each(let link in Array.slice(content.document.links)){link.textContent = link.href}
釣りリンクは見抜けるかも?
トグルできたら使いやすくなるのかなー
覚書 | |
大体ヘルプ見ればわかると思います!!
コマンドラインモードだけでも結構キー操作が豊富なので自分の為にまとめておこうと思った
大体Ctrlキーと一緒に使うものばかりです。aの隣にctrlが無い人はフリーソフトや設定などでctrlにしましょう!
使い辛いやつもあるので、cmapとかするといいと思います
例えば、<C-v><C-w>ならそのタブが閉じる
<C-v><C-x>なら選択中の文字を切り取る
<C-v><C-z>なら元に戻る
これはcnoremapして本領を発揮するはず
コマンドラインモードではInsertモードとか他モードと違ってPASS THROUGHモードとか表示されないのでわかりづらい・・・
:abbr r ルーピー鳩山
としておくと、
:tabopen r
のときに<C-]>を押すと
:tabopen ルーピー鳩山
となる!
"や'などのクォーテーション文字でも略語展開できます
書いてみた | |
もう既にそういうのはあったりするかもしれないですが、書いてみる
" タブ上にある全ての画像を保存するコマンド " -cオプションでタブを閉じながら保存 let g:imageSaveDirectory = "~/Pictures/" let g:saveAndClose = "false" javascript <<EOM commands.addUserCommand( ['saveallimage'], 'save all image in tabs', function(args) { let mTabs = document.getElementById("content").mTabs; let index = -1; let closes = 0; function closeTab(i) { if( args["-close"] || eval(liberator.globalVariables.saveAndClose) ) { let ts = getBrowser().tabContainer.childNodes; getBrowser().removeTab(ts[i - closes]); ++closes; } }; function isTextType(url){ try{ const ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); let ch = ioService.newChannel(url, "UTF-8", null); let stream = ch.open(); return ch.contentType.match(/^text/); }catch(e){liberator.echoerr(e)}; return true; }; function downloadImage(url,file,leafname) { if ( !file.exists() || args.bang ){ //以下の1行でもほぼOKだけど、保存先がどうしても変更できない・・・ //saveImageURL(url,targetpath,null,true,makeURI(url,getCharsetforSave(null))); //URLからダウンロードする const dm = Cc["@mozilla.org/download-manager;1"].getService(Ci.nsIDownloadManager); let persist = makeWebBrowserPersist(); try{ let to_file = services.create('file'); to_file.initWithPath(file.path); let to_uri = makeFileURI(to_file); let from_uri = makeURI(url,null,null); let download = dm.addDownload(0, from_uri, to_uri, leafname, null, null, null, null, persist); persist.progressListener = download; persist.saveURI(from_uri, null, null, null, null, to_file); liberator.echo("Save : " + file.path); }catch(e){liberator.echoerr(e)} }else{ liberator.echoerr("E13: File exists (add ! to override) : " + file.path); } }; for each ( [,tab] in tabs.browsers ) { ++index; let lb = mTabs[index-closes].linkedBrowser; let bartabURL = lb.userTypedValue ? lb.userTypedValue : lb.mIconURL; let url = bartabURL ? bartabURL : tab.currentURI.spec; if( url.match(/\.(jpe?g|gif|png|bmp)$/i) ){ //URLの拡張子だけで判別すると404とかだったときに困るのでMIME-TYPEからも調べる if( isTextType(url) ) { closeTab(index); continue; } //ファイル名取得 let leafname = url.split(/\/+/g).pop(); let targetpath = liberator.globalVariables.imageSaveDirectory + leafname; let file = io.File(targetpath); downloadImage(url,file,leafname); closeTab(index); } } }, { bang: true, options: [ [["-close", "-c"], commands.OPTION_NOARG], ] } ); EOM
:saveallimageで全ての画像を保存(ファイルが既に存在する場合は保存しない)
-closeオプションを付けると画像を保存しつつタブを閉じる(グローバル変数でもセットできる)
グローバル変数でデフォルトの保存先をあらかじめ指定しておく必要がある
:saveallimage!とすると強制的に上書き保存する
こんなに長くなってしまった\(^o^)/
プラグインとして書いた方がよかったかも・・・
画像を保存するヒントモードを作った - vimpめも - vimperatorグループ
#vimperator プラグイン: ZIPでダウンロードするお! - Vimple Star Sprites - vimperatorグループ
ありがとうございました!
Vimperator2.3のみで動作しました
Windowsの場合は let g:imageSaveDirectory = "C:\hoge\"とかすると動くと思います
いつかできたらいいなという期待を込めておきました!