User:Nthep/googletitle.js

//Add Google search - modified from User:Writ Keeper/Scripts/googleTitle.js to include articles in Draft namespace// $(googleTitle); function googleTitle {		if(mw.config.get('wgCanonicalNamespace') === ""||mw.config.get('wgCanonicalNamespace') =='Draft') {			var subjectName; if(mw.config.get('wgPageName').charAt(mw.config.get('wgPageName').length - 1) == ")")			{				subjectName = mw.config.get('wgPageName').substring(0, mw.config.get('wgPageName').lastIndexOf("(") - 1); }			else {				subjectName = mw.config.get('wgPageName'); }			if(mw.config.get('wgCanonicalNamespace') =='Draft') // this if statement strips Draft: from the start of the search string // {				subjectName = mw.config.get('wgPageName').substring(6); }			var searchNode = document.createElement("a"); searchNode.href = "https://www.google.com/search?q=" + encodeURIComponent(subjectName.replace(/_/g, " ")) + "+-wikipedia.org"; searchNode.target = "_blank"; searchNode.innerHTML = " Search Google "; document.getElementById("firstHeading").appendChild(searchNode); } }