MediaWiki:Gadget-SousPages.js

From Meta, a Wikimedia project coordination wiki

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
var subPagesLink = function ($) {
  var NSWithoutSubpages = new Array(-1, 6, 14);
  if (NSWithoutSubpages.indexOf(mw.config.get('wgNamespaceNumber')) == -1){
    console.log(mw.message( 'Subpages' ));
    mw.util.addPortletLink(
      'p-tb',
      mw.config.get('wgServer') + '/wiki/Special:PrefixIndex/' + mw.config.get('wgPageName'),
      mw.msg( 'gadget-souspages-subpages' )
    );
  }
}
$(document).ready(
  function ($) {
    var api = new mw.Api();
    api.loadMessagesIfMissing( [ 'gadget-souspages-subpages' ] ).done( subPagesLink );
  }
);