Google access keys

By ms609 Last update Nov 16, 2009 — Installed 373 times. Daily Installs: 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0, 0, 0, 1, 0, 0, 0, 2

There are 2 previous versions of this script.

// ==UserScript==
// @name           Google access keys
// @namespace      google.com
// @description    Allows the type of Google search to be changed quickly using "Shift - Alt acceskeys (Apple: Option key)".
// @include        http://*.google.*
// @version        0.12 - Remove 'Scholar pro' link and improve positioning of Wikipedia link
// @exclude        http://*.google.com/ig
// @exclude        http://*.google.com/a/*
// ==/UserScript==

var links = document.getElementsByTagName("a"); morelink=false;
for (i=0; i<links.length; i++) {
	if (links[i].innerHTML == "Scholar") {links[i].accessKey = "s"; var scholar = links[i];}
	else if (links[i].innerHTML == "Web") {links[i].accessKey = "w";}
	else if (links[i].innerHTML == "Images") {links[i].accessKey = "i";}
	else if (links[i].innerHTML == "News") {links[i].accessKey = "n";}
	else if (links[i].innerHTML == "Maps") {links[i].accessKey = "m";}
	else if (links[i].innerHTML == "Groups") {links[i].accessKey = "g";}
	else if (links[i].innerHTML == "Products") {links[i].accessKey = "p";}
	else if (links[i].className == "gb3" ) {morelink = links[i];}
}

// The code beneath this line adds the "Scholar Pro" and Wikipedia links. 
// Delete everything from here down if you want rid of them!

if (morelink && typeof('morelink') != "undefined") {
	
	//Wikipedia
	wiki = document.createElement("a");
	wiki.accessKey = ("d");
	wiki.style.fontWeight = "normal";
	wiki.className = "q";
	wiki.innerHTML = "Wikipedia";
	w = /\Wq=([^&]*)/;
	if (window.location.href.match(w)) {
		var wikisearch = w.exec(window.location.href);
		wiki.href = "http://en.wikipedia.org/w/index.php?title=" + wikisearch[1];
	} else {wiki.href = "http://en.wikipedia.org/wiki/Special:Search?fulltext=Search";}
	space = document.createElement("span");
	space.innerHTML = "&nbsp;&nbsp;";
	morelink.parentNode.insertBefore(wiki, morelink);
	morelink.parentNode.insertBefore(space, morelink);
}