Wikipedia:WikiProject User scripts/Scripts/Get user name

This is an old revision of this page, as edited by Lupin (talk | contribs) at 12:11, 17 August 2006 (short version of get user name function using special page variables). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

//

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

function getUserName(){

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

}
//