vForums Support > Programming & Coding :: Code Requests & Support :: > [F] Prename

[F] Prename - Posted By XeroCint (kai) on 1st Jan 08 at 10:24pm
is there a way that I could have a code in which that you add onto the username. Basically I want all my users to have a tS: at the beginning of their username

Re: Prename - Posted By Michael (wrighty) on 1st Jan 08 at 10:25pm
of their username? {Shocked}

Or their displayname?

Re: Prename - Posted By XeroCint (kai) on 1st Jan 08 at 10:38pm
displayname, sorry for the mix up {Cheesy}

Re: Prename - Posted By Michael (wrighty) on 1st Jan 08 at 10:44pm
try this:

Code:
 
  1. <script>
  2. var pref = 'tS: '; //This is the prefix
  3.  
  4. var a = document.getElementsByTagName('a');
  5. for(i=0;i<a.length;i++){
  6.     if(a[i].href.match(/\/view_profile\//i) && a[i].href.match(/\/user\//)){
  7.         a[i].innerHTML= pref + a[i].innerHTML
  8.     }
  9. }
  10. </script>
 


Simply modify: var pref = ...

That should do it! {Smile}

Re: Prename - Posted By XeroCint (kai) on 1st Jan 08 at 11:06pm
Hehe, you're the greatest Wrighty {Cheesy}

Re: Prename - Posted By Michael (wrighty) on 1st Jan 08 at 11:13pm
Glad it worked! {Smile}

Re: [F] Prename - Posted By Marc (cr0w) on 2nd Jan 08 at 3:06am
Just so that people don't accidentally end up having double of the "tS:" in their name, you could try this:

Code:
 
  1. <script>
  2. var pref = 'tS: '; //This is the prefix
  3.  
  4. var a = document.getElementsByTagName('a');
  5. for(i=0;i<a.length;i++){
  6.     if(a[i].href.match(//view_profile//i) && a[i].href.match(//user//) && !a[i].innerHTML.match(new RegExp(pref,"i"))){
  7.         a[i].innerHTML= pref + a[i].innerHTML
  8.     }
  9. }
  10. </script>
 

Re: [F] Prename - Posted By XeroCint (kai) on 2nd Jan 08 at 3:41am
thanks I had to go through everyone in the forum that already had it (everyone -__-) and fix

Re: [F] Prename - Posted By Marc (cr0w) on 2nd Jan 08 at 3:51am
 
thanks I had to go through everyone in the forum that already had it (everyone -__-) and fix


Haha, sorry that I was a bit late. {Tongue Out}

Re: [F] Prename - Posted By XeroCint (kai) on 2nd Jan 08 at 4:01am
actually it doesn't work.. {Tongue Out}

Re: [F] Prename - Posted By Marc (cr0w) on 2nd Jan 08 at 4:08am
 
actually it doesn't work.. {Tongue Out}


Thought it might not; hold on, I know what the error is. {Smile}

EDIT: Hmm, for some reason when I copied it the first time it removed some backslashes. {Unsure}

Code:
 
  1. <script>
  2. var pref = 'tS: '; //This is the prefix
  3.  
  4. var a = document.getElementsByTagName('a');
  5. for(i=0;i<a.length;i++){
  6.     if(a[i].href.match(/\/view_profile\//i) && a[i].href.match(/\/user\//) && !a[i].innerHTML.match(new RegExp(pref,"i"))){
  7.         a[i].innerHTML= pref + a[i].innerHTML
  8.     }
  9. }
  10. </script>
 


There ya go. {Smile}