blob: b2436b23e51148e88c4a98c75996480331e6e995 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
// INFO {{{
let PLUGIN_INFO = xml`
<VimperatorPlugin>
<name>google-exopen</name>
<description>useful in google search</description>
<description lang="ja">openを拡張し前回のGoogle検索クエリを入力済みにする</description>
<author>akameco</author>
<license>New BSD License</license>
<version>0.1</version>
</VimperatorPlugin>`;
// }}}
(function () {
let original = mappings.getDefault(modes.NORMAL, 'o');
mappings.addUserMap(
[modes.NORMAL],['o'],':open',
function() {
// urlを取得
var url = window.content.window.location;
// google検索か判定
if(url.host !== 'www.google.co.jp') {
return original.action.apply(this, arguments);
}
// クエリ部の抜き出し
var q = url.href.match(/[?&]q=(.*?)&/);
// コマンドの引数
// foo+bar+hogeの形で取得されるので'+'を' 'で置き換え
var commandPram = decodeURIComponent(q[1]).replace(/\+/g,' ');
// コマンドの生成
var command = 'open ' + commandPram;
commandline.open('',
commands.commandToString(
{
command: command
}
),modes.EX);
}
);
})();
// vim:sw=2 ts=2 et si fdm=marker:
|