User:Danski454/ShortcutNamespaces.js

$(document).ready(function{	var api = new mw.Api;	if (mw.config.get( 'wgPageName' ) === 'Special:Search'){		var searchText = ;		var params = location.search.substring(1).split('&');		for (var i = 0; i < params.length; i++) {			if (/\??search=.*/.test(params[i])){//find search text				searchText = params[i].split('=')[1];			}		}		searchText = decodeURIComponent(searchText.replace(/\+/g, ' ')); //convert from URI to normal text		pseudoNamespacePage = getTarget(searchText);		if (pseudoNamespacePage.length !== 0){			api.parse("You may be looking for " + pseudoNamespacePage + ".''").done(function(data){ $('.mw-search-results').prepend(data); });		}	} });

function getTarget(text){ var finalPage = ''; if (text.indexOf(':') !== -1){ var afterColon = text.slice(text.indexOf(':')); var pseudoNamespace = text.split(':')[0].toUpperCase; switch (pseudoNamespace){ case "C": case "CAT": finalPage = "Category" + afterColon; break; case "H": finalPage = "Help" + afterColon; break; case "P": finalPage = "Portal" + afterColon; break; case "T": finalPage = "Template" + afterColon; break; }	}	return finalPage; }