User:7/namespace redirect.js

/*	NAMESPACE REDIRECT Description: Redirects pages that begin with certain prefixes to appropriate namespaces. Example: Test -> Category:Test, F:Test ->, T:Test -> Template:Test Original Link: User:Gary King/namespace redirect.js More Example: UT:Test -> User Talk:Test, L:Test.com -> runs an spamlink check on test.com

addOnloadHook(function {	if (mw.config.get('wgPageName') != 'Special:Search') return;	var searchText = document.getElementById('searchText');	if (!searchText) return;	var searchTerm = searchText.value;	var colon = searchTerm.indexOf(':');

if (colon != -1) {		var firstPart = searchTerm.substring(0, colon); var secondPart = searchTerm.substring(colon + 1); var pageName = ''; switch (firstPart.toUpperCase) {			case 'C': pageName = 'Category:' + secondPart; break; case 'F': pageName = 'File:' + secondPart; break; case 'T': pageName = 'Template:' + secondPart; break; case 'U': pageName = 'User:' + secondPart; break;

/* add in User Talk namespace shortcut */ case 'UT': pageName = 'User Talk:' + secondPart; break; /* add in shortcut to do a link search for spam fighters*/ case 'L': pageName = 'Special:LinkSearch/*.' + secondPart; break;

}		if (pageName != '') window.location = mw.config.get('wgServer') + '/wiki/' + pageName; } });