From e41eb4be6ff8544d40b689368d11ef808d0ac8bb Mon Sep 17 00:00:00 2001 From: Huawei Date: Tue, 28 Feb 2012 10:15:39 -0600 Subject: initial commit --- google-results.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 google-results.js (limited to 'google-results.js') diff --git a/google-results.js b/google-results.js new file mode 100755 index 0000000..9ef3866 --- /dev/null +++ b/google-results.js @@ -0,0 +1,29 @@ +/** +* ==VimperatorPlugin== +* @name google-results.js +* @description helps to select google results +* @author john bower (whiskeytangobravo@gmail.com, http://www.whatsthebeef.org) +* @version 0.1 +* @minversion 2.0pre +* ==/VimperatorPlugin== +* +* LICENSE +* Creative Commons +* +* USAGE +* +* EXAMPLE +* +* HISTORY +* 2012/02/27 ver. 0.1 - initial written. +* +*/ + +(function() { + +commands.addUserCommand(["gr"], + "Google Results", + function (args) { + window.content.document.querySelectorAll("div > ol > li > div > h3 > a")[args].click(); + }); +})(); -- cgit v1.2.3 From 98a068dc23ddc7c7f5e405087d816a4d7d72fd62 Mon Sep 17 00:00:00 2001 From: whatsthebeef Date: Tue, 28 Feb 2012 10:23:21 -0600 Subject: neatened up description --- google-results.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'google-results.js') diff --git a/google-results.js b/google-results.js index 9ef3866..14161c7 100755 --- a/google-results.js +++ b/google-results.js @@ -1,8 +1,8 @@ /** * ==VimperatorPlugin== * @name google-results.js -* @description helps to select google results -* @author john bower (whiskeytangobravo@gmail.com, http://www.whatsthebeef.org) +* @description provides quick access to google results +* @author whatsthebeef (whiskeytangobravo@gmail.com, http://www.whatsthebeef.org) * @version 0.1 * @minversion 2.0pre * ==/VimperatorPlugin== @@ -11,8 +11,15 @@ * Creative Commons * * USAGE -* +* :gr [index] +* index - the index of the result you would like to access +* * EXAMPLE +* keys can be mapped like so +* nmap ,1 :gr0 +* nmap ,2 :gr1 +* etc... +* the you only need to press ,1 to access first result... * * HISTORY * 2012/02/27 ver. 0.1 - initial written. -- cgit v1.2.3 From be1c16b8ae168a8b4187bb7a931aafb404eecebe Mon Sep 17 00:00:00 2001 From: whatsthebeef Date: Wed, 29 Feb 2012 17:25:24 -0600 Subject: added ability to select suggestion and changed from position to index --- google-results.js | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'google-results.js') diff --git a/google-results.js b/google-results.js index 14161c7..1118106 100755 --- a/google-results.js +++ b/google-results.js @@ -11,18 +11,21 @@ * Creative Commons * * USAGE -* :gr [index] -* index - the index of the result you would like to access +* :gr [position] +* position - the position of the result you would like to access +* if position = 0 it will use the suggestion or if there isn't one with will +* search same string again * * EXAMPLE * keys can be mapped like so -* nmap ,1 :gr0 -* nmap ,2 :gr1 +* nmap ,0 :gr0 +* nmap ,1 :gr1 +* nmap ,2 :gr2 * etc... * the you only need to press ,1 to access first result... * * HISTORY -* 2012/02/27 ver. 0.1 - initial written. +* 2012/02/29 ver. 0.2 - initial written. * */ @@ -31,6 +34,18 @@ commands.addUserCommand(["gr"], "Google Results", function (args) { - window.content.document.querySelectorAll("div > ol > li > div > h3 > a")[args].click(); + var doc = window.content.document; + if(args >= 1) { + var results = doc.querySelectorAll("div > ol > li > div > h3 > a"); + if(args <= results.length) { + results[args - 1].click(); + } + else { + console.error("Not that many results"); + } + } + else { + (doc.querySelector("div > p > a.spell") || doc.querySelector("div > button")).click(); + } }); })(); -- cgit v1.2.3