User:Glaisher/scripts/search.js

// Originally User:Writ_Keeper/Scripts/googleTitle.js. Unstable version below by me.

addOnloadHook(googleTitle);

function googleTitle {		if(wgCanonicalNamespace == "") {			var subjectName; if(wgPageName.charAt(wgPageName.length - 1) == ")")			{				subjectName = wgPageName.substring(0, wgPageName.lastIndexOf("(") - 1); }			else {				subjectName = wgPageName; }			var searchNode = document.createElement("a"); searchNode.href = "http://www.google.com/search?q=" + subjectName.replace(/_/g, " ") + "+-wikipedia"; searchNode.target = "_blank"; searchNode.innerHTML = " Search Google — "; document.getElementById("firstHeading").appendChild(searchNode); }			{			var searchNode = document.createElement("a"); searchNode.href = "http://www.google.com/search?q=" + subjectName.replace(/_/g, " ") + "&tbm=nws&tbs=ar:1" searchNode.target = "_blank"; searchNode.innerHTML = " news "; document.getElementById("firstHeading").appendChild(searchNode); }			{			var searchNode = document.createElement("a"); searchNode.href = "http://images.google.com/images?safe=off&as_rights=(cc_publicdomain%7ccc_attribute%7ccc_sharealike%7ccc_noncommercial%7ccc_nonderived)&q=" + subjectName.replace(/_/g, " ") ; searchNode.target = "_blank"; searchNode.innerHTML = " free images "; document.getElementById("firstHeading").appendChild(searchNode); }

{			var searchNode = document.createElement("a"); searchNode.href = "http://www.google.com/search?tbs=bks:1&q=" + subjectName.replace(/_/g, " ") ; searchNode.target = "_blank"; searchNode.innerHTML = " books "; document.getElementById("firstHeading").appendChild(searchNode); } }