Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// Intended to be used to make IRC help links use a default nick that's much// easier to work with// Author: PhantomTech$(document).ready(function($,mw){varuserNick;var$ircLink=$('#ircLink');/** * Pick a random nick. * * Uses a randomly selected color to get a "user-friendly" nick. * Nicks are given in the format [color]-WP[number] where [color] is * the random color and [number] is a random number between 100 and 999. * * @return {string} Nick */functiongetRandomNick(){// Might not be a bad idea to have some more colorsvarnickOptions=['red','pink','orange','yellow','green','cyan','blue','purple'];returnnickOptions[Math.floor(Math.random()*7)]+'-WP'+Math.floor(Math.random()*900+100).toString();}/** * Pick a random nick based on user's username. * * Uses the user's username to get a "user-friendly" nick. Nicks are * given in the format [username]-WP[number] where [username] is the * username with non-alphanumeric characters replaced with an underscore * and [number] is a random number between 10 and 99. * * @return {string} Nick */functiongetUsernameNick(){returnmw.user.getName().substring(0,11).replace(/\W/g,'_')+'-WP'+Math.floor(Math.random()*90+10).toString();}// 'User:PhantomTech/sandbox/IRC_Disclaimer' will be replacedif(mw.config.get('wgPageName')==='User:PhantomTech/sandbox/IRC_Disclaimer'){// Check to make sure the link exists, then set the nickif($ircLink.length){if(mw.user.isAnon()){userNick=getRandomNick();}else{userNick=getUsernameNick();varunderscoreCount=0;for(vari=0;i<userNick.length;i++){if(userNick.charAt(i)==='_'){underscoreCount++;}}// If nick has so many underscores that it probably isn't usefulif(underscoreCount>4){userNick=getRandomNick();}}$ircLink.html($ircLink.html().replace(/WPhelp\?/,userNick));}}}(jQuery,mediaWiki));