Created
February 20, 2011 09:21
-
-
Save awq/835842 to your computer and use it in GitHub Desktop.
Vimperator configuration
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
set hinttimeout=250 | |
map \\ <F12> | |
"minimize | |
js <<EOM | |
commands.addUserCommand(['mi[nimize]'], "minimize window", | |
function(){ | |
minimize(); | |
}, {}, true); | |
EOM | |
" e=>:echo, E=>:echo! | |
js <<EOM | |
mappings.addUserMap( | |
[modes.NORMAL], | |
["v"], | |
":tw", | |
function(){ | |
liberator.execute(":style -name commandline-ime chrome://* #liberator-commandline-command input { ime-mode: active; }", true, true); | |
commandline.open(":", "tw ", modes.EX); | |
liberator.execute(":style -name commandline-ime chrome://* #liberator-commandline-command input { ime-mode: inactive; })", true, true); | |
}, | |
{ | |
rhs: ":tw" | |
} | |
); | |
mappings.addUserMap( | |
[modes.NORMAL], | |
["V"], | |
":tw TITLE URL", | |
function(){ | |
commandline.open(":", "tw " + buffer.title + " " + buffer.URL, modes.EX); | |
}, | |
{ | |
rhs: ":tw TITLE URL" | |
} | |
); | |
EOM | |
"ime-controller | |
style -name commandline-ime chrome://* #liberator-commandline-command input { ime-mode: inactive; } | |
"hatena bookmark | |
js <<EOM | |
commands.addUserCommand(['hb'], "hatena bookmark", | |
function(){ | |
var l = content.location, h = l.href; | |
h = h.replace(RegExp('#'), '%23').replace(RegExp('^https://'), 'http://s/').replace(RegExp('^http://(.*)'), 'http://b.hatena.ne.jp/entry/$1'); | |
l.href = h; | |
}, {}, true); | |
EOM | |
"r$, x$ | |
js <<EOM | |
r$ = function () { | |
let ary = []; | |
for (var i = 0, l = arguments.length; i < l; i++) { | |
ary.push(arguments[i].r$()); | |
} | |
return ary; | |
}; | |
x$ = function () { | |
let ary = []; | |
for (var i = 0, l = arguments.length; i < l; i++) { | |
ary.push(arguments[i].x$()); | |
} | |
return ary; | |
}; | |
String.prototype.r$ = function (count) { | |
var count = count || 15000; | |
var regex = this; | |
if (/(?:^|[^\\])\./.test (regex)) liberator.echoerr ("warning: regex contains raw '.':" + regex); | |
var doc = content.document; | |
var loc = content.location.href; | |
var start = new Date(); | |
var result = (function (regex) { | |
for (var i = 1; i < count; i++) { | |
loc.match (regex); | |
} | |
return loc.match (regex); | |
})(regex); | |
var end = new Date(); | |
return ['regex = ' + regex, 'count = ' + count, 'result = ' + result, 'time[ms] = ' + (end.getTime () - start.getTime ())]; | |
}; | |
String.prototype.x$ = function (count) { | |
var count = count || 2000; | |
var xpath = this; | |
var doc = content.document; | |
var start = new Date (); | |
var result = (function (xpath) { | |
for (var i = 1; i < count; i++) { | |
doc.evaluate (xpath, doc, null, 7, null); | |
} | |
return doc.evaluate (xpath, doc, null, 7, null); | |
})(xpath); | |
var end = new Date (); | |
return [xpath, 'count = ' + count, 'snapshotLength = ' + result.snapshotLength, 'time[ms] = ' + (end.getTime () - start.getTime ())]; | |
}; | |
EOM | |
"ignore key | |
js config.ignoreKeys["<Space>"] = 2 | |
"Awesomebarの補完対象にBookmarkletを含める。ついでに補完件数を増やす | |
"http://retlet.net/log/2008/06/awesomebar-bookmarklet.html | |
set! browser.urlbar.filter.javascript=false | |
set! browser.urlbar.maxRichResults=20 | |
"edit _vimperatorrc | |
js <<EOM | |
commands.addUserCommand(['er'], "edit _vimperatorrc", | |
function(){ | |
GM_launchApplicationWithDoc(GM_getEditor(),{path: liberator.modules.io.expandPath('~/_vimperatorrc')}); | |
}); | |
EOM | |
"editor設定 | |
set editor="D:/y/!_App/!_Text/EmEditor/EmEditor.exe /sp /cp 65001" | |
"'complete' 'cpt' :[tab]open で補完される項目(sfl) | |
"s サーチエンジンの名前 ( 訳注: :dialog searchengines で表示されるものです ) とブックマークキーワード | |
"f ローカルファイル | |
"l Firefox の Awesome bar ( ロケーションバーのことです ) に表示される項目 | |
"b ブックマーク | |
"S サジェストエンジン ( 訳注: Google や Yahoo! などからの検索キーワードの提示です ) | |
set cpt=lS | |
set defsearch="google" | |
"set suggestengines="google,wpja" | |
" e=>:echo, E=>:echo! | |
js <<EOM | |
mappings.addUserMap( | |
[modes.NORMAL], | |
["e"], | |
":echo", | |
function(){ | |
commandline.open(":", "echo ", modes.EX); | |
}, | |
{ | |
rhs: ":echo" | |
} | |
); | |
mappings.addUserMap( | |
[modes.NORMAL], | |
["E"], | |
":echo!", | |
function(){ | |
commandline.open(":", "echo! ", modes.EX); | |
}, | |
{ | |
rhs: ":echo!" | |
} | |
); | |
EOM | |
" x=>toggle AutoPagerize, X=>toggle AutoPagerizeScroll | |
js <<EOM | |
mappings.addUserMap( | |
[modes.NORMAL], | |
["x"], | |
"toggle AutoPagerize", | |
function() { | |
(function (frames) { | |
var ary = []; | |
for (var i = 0, l = frames.length; i < l; i++) { | |
ary.push (frames[i]); | |
if (frames[i].frames.length) { | |
ary = ary.concat (arguments.callee (frames[i].frames)); | |
} | |
} | |
return ary; | |
}) ([content]).forEach (function (frame) { | |
var doc = frame.document; | |
var element = doc.evaluate ('id("autopagerize_help")//*[@class="autopagerize_link"]', doc, null, 8, null).singleNodeValue; | |
if (element) { | |
var event = doc.createEvent ('MouseEvents'); | |
event.initEvent ('click', true, true); | |
element.dispatchEvent (event); | |
} | |
}); | |
}, | |
{ | |
rhs: "toggle AutoPagerize" | |
} | |
); | |
mappings.addUserMap( | |
[modes.NORMAL], | |
["X"], | |
"toggle AutoPagerizeScroll", | |
function () { | |
(function (frames) { | |
var ary = []; | |
for (var i = 0, l = frames.length; i < l; i++) { | |
ary.push (frames[i]); | |
if (frames[i].frames.length) { | |
ary.push (arguments.callee (frames[i].frames)); | |
} | |
} | |
return ary; | |
}) ([content]).forEach (function (frame) { | |
var doc = frame.document; | |
var element = doc.evaluate ('id("autopagerize_icon")', doc, null, 8, null).singleNodeValue; | |
if (element) { | |
var event = doc.createEvent ('MouseEvents'); | |
event.initEvent ('dblclick', true, true); | |
element.dispatchEvent (event); | |
} | |
}); | |
}, | |
{ | |
rhs: "toggle AutoPagerizeScroll" | |
} | |
); | |
EOM | |
" optionvalue | |
js <<EOF | |
liberator.globalVariables.options_migrate_user_pref = | |
[ | |
/*{ | |
pref: 'javascript.enabled', | |
description: 'Using JavaScript', | |
command: ['javascript', 'js'], | |
}, | |
{ | |
pref: 'refcontrol.enabled', | |
description: 'Using RefControl', | |
command: ['refcontrol', 'ref', 'r'], | |
}*/ | |
]; | |
EOF | |
" h,j,k,lでのスクロール量変更 | |
js <<EOM | |
/* | |
(function(){ | |
var scrollDistance = SuperScroll.scrollDistance? SuperScroll.scrollDistance: 88; | |
mappings.addUserMap( | |
[modes.NORMAL], | |
["h"], | |
"5 lines left", | |
function(){ | |
document.commandDispatcher.focusedWindow.scrollBy(-scrollDistance, 0) | |
//buffer.scrollLines(5) | |
} | |
); | |
mappings.addUserMap( | |
[modes.NORMAL], | |
["j"], | |
"5 lines down", | |
function(){ | |
document.commandDispatcher.focusedWindow.scrollBy(0, scrollDistance) | |
//buffer.scrollLines(5) | |
} | |
); | |
mappings.addUserMap( | |
[modes.NORMAL], | |
["k"], | |
"5 lines up", | |
function(){ | |
document.commandDispatcher.focusedWindow.scrollBy(0, -scrollDistance) | |
//buffer.scrollLines(-5) | |
} | |
); | |
mappings.addUserMap( | |
[modes.NORMAL], | |
["l"], | |
"5 lines right", | |
function(){ | |
document.commandDispatcher.focusedWindow.scrollBy(scrollDistance, 0) | |
//buffer.scrollLines(-5) | |
} | |
); | |
})(); | |
*/ | |
(function(){ | |
var repeatScroll = { | |
isCaret : function(){ | |
return Cc["@mozilla.org/preferences-service;1"] | |
.getService(Components.interfaces.nsIPrefBranch) | |
.getBoolPref('accessibility.browsewithcaret') | |
}, | |
up : function (num){ | |
if (this.isCaret() || !num) num = 1; | |
for (var i = 0; i < num; i++) | |
goDoCommand('cmd_scrollLineUp'); | |
}, | |
down : function (num){ | |
if (this.isCaret() || !num) num = 1; | |
for (var i = 0; i < num; i++) | |
goDoCommand('cmd_scrollLineDown'); | |
}, | |
left : function (num){ | |
if (this.isCaret() || !num) num = 1; | |
for (var i = 0; i < num; i++) | |
goDoCommand('cmd_scrollLeft'); | |
}, | |
right : function (num){ | |
if (this.isCaret() || !num) num = 1; | |
for (var i = 0; i < num; i++) | |
goDoCommand('cmd_scrollRight'); | |
} | |
}; | |
mappings.addUserMap( | |
[modes.NORMAL], | |
["h"], | |
"5 lines left", | |
function(){ | |
repeatScroll.left(5); | |
} | |
); | |
mappings.addUserMap( | |
[modes.NORMAL], | |
["j"], | |
"5 lines down", | |
function(){ | |
repeatScroll.down(5); | |
} | |
); | |
mappings.addUserMap( | |
[modes.NORMAL], | |
["k"], | |
"5 lines up", | |
function(){ | |
repeatScroll.up(5); | |
} | |
); | |
mappings.addUserMap( | |
[modes.NORMAL], | |
["l"], | |
"5 lines right", | |
function(){ | |
repeatScroll.right(5); | |
} | |
); | |
})() | |
EOM | |
" スペースキーでのスクロール量変更 | |
" event.jsを修正 | |
" http://vimperator.g.hatena.ne.jp/snaka72/20090301/1235865914 | |
nnoremap <Space> <C-f> | |
nnoremap <S-Space> <C-b> | |
" sで読み込み中止 | |
noremap s <C-c> | |
" コマンドモード、挿入モードではC-zでundo | |
cnoremap <C-z> <C-v> <C-z> | |
inoremap <C-z> <C-v> <C-z> | |
" ウィンドウのタイトル=Vimperator | |
set titlestring=Vimperator | |
" ビープ音もvisualbellもオフ | |
set visualbell | |
hi Bell display:none | |
" メニューバーを表示 | |
set guioptions=mrb | |
" 選択文字列のコピーを <C-c> に割り当て | |
" noremap <C-c> :echo 'Yank!'<CR>Y | |
" Backspace に戻るを割り当て | |
" map <BS> <A-Left> | |
" 検索結果をハイライト | |
set hlsearch | |
" 常にタブを表示 | |
set showtabline=2 | |
" Tabキー押さなくても自動補完 | |
"set wildoptions=auto | |
" 履歴を10000件 | |
set history=0 | |
" 自動でテキストエリアにフォーカスしない(なんか微妙) | |
set focuscontent | |
" 設定ファイルを再読み込み | |
" noremap <C-S> :so ~/_vimperatorrc<CR> | |
" noremap <C-D> :mapc<CR>:cmapc<CR>:imapc<CR>:so ~/_vimperatorrc<CR> | |
" 左右のタブへ | |
nnoremap , <C-S-Tab> | |
nnoremap . <C-Tab> | |
" tab closer | |
js <<EOM | |
var removeTabs = function(from, to){ | |
if(from == 0 && to == gBrowser.mTabs.length - 1){ | |
for(var i = to; i >= 1; i--) gBrowser.removeTab(gBrowser.mTabs[i]); | |
liberator.modules.tabs.remove(gBrowser.mTabs[0]); | |
} | |
else{ | |
for(var i = to; i >= from; i--) gBrowser.removeTab(gBrowser.mTabs[i]); | |
} | |
} | |
commands.addUserCommand(["kl"], "kill left tabs", | |
function(){ | |
removeTabs(0, gBrowser.mCurrentTab._tPos - 1); | |
}); | |
commands.addUserCommand(["kL","KL"], "keep right tabs", | |
function(){ | |
removeTabs(0, gBrowser.mCurrentTab._tPos); | |
}); | |
commands.addUserCommand(["kr"], "kill right tabs", | |
function(){ | |
removeTabs(gBrowser.mCurrentTab._tPos + 1, gBrowser.mTabs.length - 1); | |
}); | |
commands.addUserCommand(["kR","KR"], "keep left tabs", | |
function(){ | |
removeTabs(gBrowser.mCurrentTab._tPos, gBrowser.mTabs.length - 1); | |
}); | |
commands.addUserCommand(["ka"], "keep only current tab", | |
function(){ | |
liberator.modules.tabs.keepOnly(gBrowser.selectedTab); | |
}); | |
commands.addUserCommand(["kA","KA"], "kill all tabs", | |
function(){ | |
removeTabs(0, gBrowser.mTabs.length - 1); | |
}); | |
EOM | |
" hint style | |
highlight! Hint font-family: "Bitstream Vera Sans Mono",monaco,monospace; font-size: 13px; color: white; background-color: green; border-color: ButtonShadow; border-width: 0px; border-style: solid; padding: 2px; line-height: 1em; | |
" エラーコンソールに詳細表示 | |
set verbose=0 | |
"//ieTab switchEngine | |
js <<EOM | |
commands.addUserCommand(["iet[ab]"], "toggle ie tab", | |
function(){ | |
gIeTab.switchEngine(true); | |
}); | |
EOM | |
"""""""""""""""""""""""""""" | |
"Google検索結果でヒント表示したときに、検索ボックスにマッチする文字が常に一定になるようにする | |
set hintchars=hjklasdfgqwertyuopzxcbnm | |
js <<EOM | |
hints.extendedhinttags = options.get('extendedhinttags').value.replace(/\| \/\/xhtml:[^|]+/g, ''); | |
hints.hintcharsOriginal = options.hintchars; | |
hints.hintcharsFilters = []; | |
hints.addHintcharsFilter = function(url, filter) | |
{ | |
var i = 0, l = hints.hintcharsFilters.length; | |
while(i < l) | |
{ | |
if(url.length > hints.hintcharsFilters[i].url.toString().length) break; | |
i++; | |
} | |
hints.hintcharsFilters.splice(i, 0, | |
{ | |
url: RegExp(url), filter: filter, | |
}); | |
}; | |
hints.showOriginal = hints.show; | |
hints.show = function (minor, filter, win) | |
{ | |
if(!hints.hintcharsFilters.some( | |
function(v) | |
{ | |
if(v.url.test(content.location.href)) | |
{ | |
return options.hintchars = v.filter(hints.hintcharsOriginal); | |
} | |
} | |
)) | |
{ | |
options.hintchars = hints.hintcharsOriginal; | |
} | |
hints.showOriginal (minor, filter, win); | |
} | |
EOM | |
js <<EOM | |
hints.addHintcharsFilter( | |
'^http://[^/]+\\.google\\.co(?:m|\\.jp)/', | |
function(hintchars) | |
{ | |
var elems = util.evaluateXPath(hints.extendedhinttags, false); | |
var q = util.evaluateXPath('//input[@name="q"]', false).snapshotItem(0); | |
var i = 1; | |
if(content.document.getElementsByTagName('iframe').length) | |
{ | |
i--; | |
} | |
for each(elem in elems) | |
{ | |
showText = false; | |
let computedStyle = content.document.defaultView.getComputedStyle(elem, null); | |
if (computedStyle.getPropertyValue("visibility") != "visible" || computedStyle.getPropertyValue("display") == "none") | |
{ | |
continue; | |
} | |
if(elem == q || i == hintchars.length) | |
{ | |
break; | |
} | |
i++; | |
} | |
hintchars = hintchars.replace('j', ''); | |
return hintchars.slice(0, i) + 'j' + hintchars.slice(i); | |
} | |
); | |
EOM | |
" appendAnchor.js | |
let g:auto_append_anchor = "true" | |
let g:auto_append_anchor_once = "false" | |
" autopagerize_controll.js | |
let g:autopagerize_prevmap = "K" | |
let g:autopagerize_nextmap = "J" | |
"multi_requester.js | |
js <<EOM | |
liberator.globalVariables.multi_requester_siteinfo = [ | |
{ | |
bang: true, // optional: | |
name: "lsd", // required: subcommand name | |
description: "WebLSD 英和・和英検索", // required: commandline short help | |
url: "http://lsd.pharm.kyoto-u.ac.jp/cgi-bin/lsdproj/ejlookup04.pl?query=%s", // required: %s <-- replace string | |
xpath: '(//*[@class="box"])[position()>1]', // optional: default all | |
}, | |
]; | |
EOM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment