User:Digitalme/getusername.js

// /*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{ var pagename = document.getElementsByTagName('h1')[0].firstChild.nodeValue;

if ( pagename.indexOf("User:") != -1 ) { username = pagename.slice(5); } if ( pagename.indexOf("User talk:") != -1 ) { username = pagename.slice(10); } if ( pagename.indexOf("Editing User:") != -1 ) { username = pagename.slice(13); } if ( pagename.indexOf("Editing User talk:") != -1 ) { username = pagename.slice(18); }

if ( username.indexOf("/") != -1 ) { slash = username.indexOf("/"); username = username.slice(0, slash); } return username; } //