User:Zzuuzz/specialtalkpagetab.js

From Wikipedia, the free encyclopedia

If a message on your talk page led you here, please be wary of who left it. Code that you insert on this page could contain malicious content capable of compromising your account. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. If this is a .js page, the code will be executed when previewing the page.
Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.
 /*
 
  specialtalkpagetab.js
  Adds a talk page tab for special pages
 
  example:
  setting:           specialtalk_namespace = 'Foo talk';
  special page:      Special:Mywatchlist
  special talk page: Foo talk:Special:Mywatchlist
 
  Settings / default values, all are optional:
  specialtalk_namespace = 'Project talk';  // special page talk namespace
  specialtalk_label = 'discussion';        // tab label text
  specialtalk_hotkey = 't';                // hotkey
  specialtalk_portlet = 'p-cactions';      // portlet (p-navigation, p-interaction, p-tb, ...)
  specialtalk_id = 'ca-specialtalk';       // tab/node id
  specialtalk_nextnode = document.getElementById('ca-nstab-special').nextSibling;  // next tab/node, default is next to special page tab, use '' to place at end
  specialtalk_notalkfor = ['Watchlist', 'Listusers', ...];  // case-sensitive, to not add a talk page link for some pages (optional), default [] no exclusions
 
 */
 
 function specialtalkpagetab() {
  if (wgNamespaceNumber === -1) {
   if ( typeof( specialtalk_namespace ) == 'undefined' ) {
    specialtalk_namespace = 'Project talk';
   }
   if ( typeof( specialtalk_label ) == 'undefined' ) {
    specialtalk_label = 'discussion';
   }
   if ( typeof( specialtalk_hotkey ) == 'undefined' ) {
    specialtalk_hotkey = 't';
   }
   if ( typeof( specialtalk_portlet ) == 'undefined' ) {
    specialtalk_portlet = 'p-cactions';
   }
   if ( typeof( specialtalk_id ) == 'undefined' ) {
    specialtalk_id = 'ca-specialtalk';
   }
   if ( typeof( specialtalk_nextnode ) == 'undefined' ) {
    specialtalk_nextnode = document.getElementById('ca-nstab-special').nextSibling;
   }
   if ( typeof( specialtalk_notalkfor ) == 'undefined' ) {
    specialtalk_notalkfor = [];
   }
   if ( specialtalk_notalkfor.indexOf(wgTitle) == -1 ) {
    addPortletLink( specialtalk_portlet, wgScriptPath + '/index.php?title=' + specialtalk_namespace.replace(/:$/, '') + ':' + wgPageName, specialtalk_label, specialtalk_id, 'Talk page for ' + wgPageName, specialtalk_hotkey, specialtalk_nextnode );
   }
  }
 }
 
 addOnloadHook( function() {
  specialtalkpagetab();
 } )