Wikipedia:WikiProject User scripts/Scripts/Get user name

This is an old revision of this page, as edited by Tra (talk | contribs) at 22:46, 29 December 2007 (Protected Wikipedia:WikiProject User scripts/Scripts/Get user name: to avoid security being compromised on user script [edit=sysop:move=sysop]). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

/*

*/
/*This script gets a username from the current page
Example: On [[User:Digitalme/getusername.js]], getUserName() would return Digitalme
*/

function getUserName(){

  switch (wgCanonicalNamespace) {
    case 'User': case 'User_talk': return wgTitle.split('/')[0];
    default: return null;
  }

}
/*

*/