Many times I search for a keyword that I really just want a direct launch to the site.
e.g., I'll type "Stack Overflow" in the google search bar and then click the first link. Instead, I would like to simply go to stackoverflow.com. Obviously there are bookmarks and typing in the addressbar but out of force of habbit and speed I do the google thing. (usually takes about 1-2 seconds rather than finding a bookmark or selecting from the address bar drop down).
Is there a greasemonkey/tampermonkey script that does this or anyone know of a simple way to do this? I want to essentially just map exact search strings(case insensitive) to urls. If I type in something else like "stack overflow greasemonkey" I want the original search.
"stackoverflow" or "stack overflow" => stackoverflow.com, "microsoft" => microsoft.com, or whatever mapping I want(by editing the script to add them).
It should be a relatively easy task. I figure there surely is something out there that does this or that can be modified to do it?
I've cooked some up, this should work both pressing ENTER on search box or clicking the search button:
// ==UserScript==
// @name Google redirects
// @namespace http://googleredirects.com/
// @version 0.1
// @description Make redirects based on google searches
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
// @match http://www.google.com/
// @copyright 2012+, cowboy_kangaroo
// ==/UserScript==
(function () {
$(document).ready(function(){
var mapping = [ "stackoverflow", "http://stackoverflow.com",
"reddit", "http://www.reddit.com",
"slashdot", "http://slashdot.org" ];
$('input[name=q]').keydown(function(e) {
if (e.keyCode == 13) {
e.preventDefault();
e.stopPropagation();
v = $(this).val();
for (i=0;i<mapping.length;i+=2) {
if (v == mapping[i]) {
window.location.href = mapping[i+1];
}
}
}
});
$("input[name='btnK']").click(function(e) {
v = $('input[name=q]').val();
for (i=0;i<mapping.length;i+=2) {
if (v == mapping[i]) {
window.location.href = mapping[i+1];
}
}
});
});
})();
I've only tested it on Chrome with Tampermonkey. Make sure to adjust the @match rule if you are using a google specific country site, like www.google.co.uk or the like.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With