aboutsummaryrefslogtreecommitdiffstats
path: root/google-exopen.js
diff options
context:
space:
mode:
authorakameco2015-04-06 20:29:51 +0900
committerakameco2015-04-06 20:29:51 +0900
commitfa505beaaffa7a6bc09813404a82ec1cac7614ac (patch)
tree679f4893a2682467b3ec722eff37f7cd1eaefa82 /google-exopen.js
parentc9da5d5fbd76de2060601b7cc43afc9fc912a426 (diff)
downloadvimperator-plugins-fa505beaaffa7a6bc09813404a82ec1cac7614ac.tar.bz2
Add google-exopen.js
Diffstat (limited to 'google-exopen.js')
-rw-r--r--google-exopen.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/google-exopen.js b/google-exopen.js
new file mode 100644
index 0000000..58596fd
--- /dev/null
+++ b/google-exopen.js
@@ -0,0 +1,40 @@
+// 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 () {
+ mappings.addUserMap(
+ [modes.NORMAL],['o'],':open',
+ function() {
+ // urlを取得
+ var url = window.content.window.location;
+ // コマンドの引数
+ var commandPram = '';
+ // google検索か判定
+ if(url.host === 'www.google.co.jp') {
+ // クエリ部の抜き出し
+ var q = decodeURI(url.href).match(/q=(.*?)&/);
+ // foo+bar+hogeの形で取得されるので'+'を' 'で置き換え
+ var commandPram = 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: