diff options
author | anekos | 2015-04-20 22:49:42 +0900 |
---|---|---|
committer | anekos | 2015-04-20 22:49:42 +0900 |
commit | db6cb4a5dd6b8c87e2aa5bdbc17aa71e76350029 (patch) | |
tree | ddbe0cff7769465490ff7968cab534fae1a3b369 | |
parent | c74ae03da64e9b47778990f6db70a169ebb95d99 (diff) | |
parent | dc4effb65781e11cd48835f3b3f2c357c1367737 (diff) | |
download | vimperator-plugins-db6cb4a5dd6b8c87e2aa5bdbc17aa71e76350029.tar.bz2 |
Merge branch 'pr/79'
-rw-r--r-- | google-exopen.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/google-exopen.js b/google-exopen.js new file mode 100644 index 0000000..b2436b2 --- /dev/null +++ b/google-exopen.js @@ -0,0 +1,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: |