quote:
Originally posted by kOMPlEXX
code:
function GetUserName ( Origin )
{
var regPath = "HKEY_LOCAL_MACHINE\\SOFTWARE\\iAvatars.com\\StuffPlug\\" +Messenger.MyUserId +"\\szTimestamp";
var Shell = new ActiveXObject("WScript.Shell");
var szTimestamp;
if ( szTimestamp = Shell.RegRead ( regPath ) )
{ var nOrigin;
nOrigin = Origin.substr(szTimestamp.length+1);
return ( nOrigin );
}
return ( Origin );
}
This returns a cleaned Username :D
In some cases, it does indeed. In other cases, it won't.
Take a look at the link markee posted earlier in this thread (
this page). It shows the format used for the timestamp. If you look at that page you can see that 1 character isn't always replaced with 1 new character. So the length property of the registry string is not a reliable way to remove the timestamp. I thought of another way, but it needs some more testing before I post it.
edit: here it is, there must be a better/easier way to do it with regular expressions, but I suck at them so I did it this way...
code:
function UnStamp(StampedNick)
{
if (StampedNick != "")
{
try
{
if (Messenger.MyUserId != undefined)
{
var WshShell = new ActiveXObject("WScript.Shell");
var SPRegPath = "HKLM\\SOFTWARE\\iAvatars.com\\StuffPlug\\"
try
{
var Splug = true;
Splug = WshShell.RegRead(SPRegPath + "DisabledFor" + Messenger.MyUserId) == 0;
} catch (e) {}
if (Splug)
{
if (WshShell.RegRead(SPRegPath + Messenger.MyUserId + "\\TimeStamps"))
{
var StampFormat = WshShell.RegRead(SPRegPath + Messenger.MyUserId + "\\szTimestamp");
if (StampFormat != "")
{
var Nick = StampedNick.split(" ").slice(StampFormat.split(" ").length).join(" ");
return Nick;
}
}
}
}
} catch (e) {}
}
return StampedNick;
}