diff options
author | anekos | 2012-03-17 00:47:19 -0700 |
---|---|---|
committer | anekos | 2012-03-17 00:47:19 -0700 |
commit | e23e30de8667a1d6662f3f39d872eefb81e51be0 (patch) | |
tree | 37a0b354c43dd5133733d4b3152183e0626430b5 | |
parent | 1ac0bcc09a10b8c62b93801c21b5bfc6bef407a3 (diff) | |
parent | be1c16b8ae168a8b4187bb7a931aafb404eecebe (diff) | |
download | vimperator-plugins-e23e30de8667a1d6662f3f39d872eefb81e51be0.tar.bz2 |
Merge pull request #16 from whatsthebeef/master
Small plugin to allow easier selection of google search results
-rwxr-xr-x | google-results.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/google-results.js b/google-results.js new file mode 100755 index 0000000..1118106 --- /dev/null +++ b/google-results.js @@ -0,0 +1,51 @@ +/**
+* ==VimperatorPlugin==
+* @name google-results.js
+* @description provides quick access to google results
+* @author whatsthebeef (whiskeytangobravo@gmail.com, http://www.whatsthebeef.org)
+* @version 0.1
+* @minversion 2.0pre
+* ==/VimperatorPlugin==
+*
+* LICENSE
+* Creative Commons
+*
+* USAGE
+* :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 ,0 :gr<Space>0<CR>
+* nmap ,1 :gr<Space>1<CR>
+* nmap ,2 :gr<Space>2<CR>
+* etc...
+* the you only need to press ,1 to access first result...
+*
+* HISTORY
+* 2012/02/29 ver. 0.2 - initial written.
+*
+*/
+
+(function() {
+
+commands.addUserCommand(["gr"],
+ "Google Results",
+ function (args) {
+ 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();
+ }
+ });
+})();
|