Jump to content

User:MrSomeone/common.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.
function shortenTabs ( )
{
   if(document.getElementById('ca-nstab-user'))     
     document.getElementById('ca-nstab-user').firstChild.innerHTML = 'usr';
   if(document.getElementById('ca-format'))
      document.getElementById('ca-format').firstChild.innerHTML = 'fmt';
   if(document.getElementById('ca-move'))
      document.getElementById('ca-move').firstChild.innerHTML = 'mv';
   if(document.getElementById('ca-edit'))
      document.getElementById('ca-edit').firstChild.innerHTML = 'edit';
   if(document.getElementById('ca-history'))
      document.getElementById('ca-history').firstChild.innerHTML = 'hist';
   if(document.getElementById('ca-talk'))
      document.getElementById('ca-talk').firstChild.innerHTML = 'tlk';
   if(document.getElementById('ca-unwatch'))
      document.getElementById('ca-unwatch').firstChild.innerHTML = 'unw';
   if(document.getElementById('ca-watch'))
      document.getElementById('ca-watch').firstChild.innerHTML = 'w';
}

function addWelcomeLinks ( )
{
   recent2.addToolboxLink('javascript:wikiUserTalkWelcome( false );', 'Welcome!', 'willkommen');
   recent2.addToolboxLink('javascript:wikiUserTalkWelcome( "nc" );', 'Welcome! (NC)', 'willkommen');
   recent2.addToolboxLink('javascript:wikiUserTalkWelcome( "anon" );', 'Welcome! (Anon)', 'willkommen');
}

function wikiUserTalkWelcome( sw )
{
   var msg = '{{subst:' + 'User:MrSomeone/Welcome}}';
   if( sw == 'nc')   { msg = '{{subst:' + 'User:MrSomeone/Welcome|nocontrib=1}}'; }
   // if( sw == 'anon') { msg = '{{subst:' + 'anon}} ~~' + '~~'; }
   if( sw == 'anon') { msg = '{{subst:' + 'welcome-anon|MrSomeone|art=}} ~~' + '~~'; }
   var willkommen = new Array(
       msg,
      'Welcome to Wikipedia!'
   );
   document.getElementById( 'wpTextbox1' ).value += "\n" + willkommen[0];
   document.getElementById( 'wpSummary' ).value   = willkommen[1];
   if( sw != 'anon' )
      document.getElementById( 'wpSave' ).click();
}

function doOnLoad ( )
{
   return false;
   shortenTabs();
   
   if (document.title.indexOf("Editing User talk:") != -1)
   {
      addWelcomeLinks();
   }
}

window.onload = doOnLoad;