Jump to content

User:Technical 13/Scripts/Teahouse IRC.js

From Wikipedia, the free encyclopedia
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.
/**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//*
 * IRC Login name changer.  wgUserName + "|TH" if registered or "Teahouse_Guest##" otherwise.
 * BY: [[User:Technical_13]]
 * 1 May 2013
*//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**/
if (mw.config.get( 'wgPageName' ) == "Wikipedia:Teahouse/Questions"){
  var StartChatting = $('span#TeahouseIRC-linkText b').text();
  if (StartChatting == "Live help chat" && wgUserName != "null"){
    var wgUserNamee = wgUserName.replace(' ', '_');
    var hrefCurrent= $('div#TeahouseIRC a').attr('href');
// replace Teahouse_Guest.. with username|TH
    var hrefReplaced = hrefCurrent.replace('Teahouse_Guest..', wgUserNamee /* + '|TH'*/);
// Inject "#wikipedia-teahouse" to the list of channels
    var hrefReplaced = hrefReplaced.replace('&channels=wikipedia-en-help', '&channels=wikipedia-en-help%2Cwikipedia-en-helpers%2Cwikipedia-teahouse');
// turn off prompt for username and channel - captcha still required.
    var hrefReplaced = hrefReplaced.replace('&prompt=1', '&prompt=0');
    $('div#TeahouseIRC a').attr('href', hrefReplaced);
  }
}