Created
June 5, 2011 00:08
-
-
Save astromatt/1008516 to your computer and use it in GitHub Desktop.
Cross platform bookmarklet for keyword search
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Cross platform bookmarklet for keyword search. | |
| * Easy to use, modify and extend. | |
| * | |
| * Author: Matt Harasymczuk, http://www.matt.harasymczuk.pl | |
| * License: Apache 2.0 License, http://www.apache.org/licenses/LICENSE-2.0.html | |
| * | |
| * How to install? | |
| * Add new bookmark in your browser, | |
| * and paste below text as a URL (bookmark) address. | |
| * | |
| * Whenever you will open this bookmark, | |
| * prompt will show up | |
| * | |
| * How to use? | |
| * Type: g hello world | |
| * Or: w Java Script | |
| * Or: img smiley | |
| */ | |
| javascript:lambda = function() { | |
| var txt = window.prompt("Command:"); | |
| if (!txt) | |
| return false; | |
| var list = txt.split(" "); | |
| var cmd = list[0]; | |
| list.splice(0, 1); | |
| var arg = list.join(" "); | |
| arg = encodeURIComponent(arg); | |
| var uri = ""; | |
| switch(cmd) { | |
| case "g": uri="https://encrypted.google.com/search?q="; break; | |
| case "img": uri="https://encrypted.google.com/search?tbm=isch&q="; break; | |
| case "y": uri="http://www.youtube.com/results?search_query="; break; | |
| case "w": uri="http://en.wikipedia.org/w/index.php?search="; break; | |
| case "en": uri="http://translate.google.com/#en|pl|"; break; | |
| case "pl": uri="http://translate.google.com/#pl|en|"; break; | |
| } | |
| window.location = uri + arg; | |
| }(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment