User:Suntooooth/randomincategory.js
// an attempt to add randomincategory to the sidebar of category pages, partially based on User:PrimeHunter/Impact.js
$( document ).ready( function() {
if (mw.config.get('wgNamespaceNumber') != "14")
return; // category namespace only
mw.util.addPortletLink(
'p-navigation', // navigation section
mw.config.get('wgArticlePath').replace("$1", "Special:RandomInCategory/"+ encodeURI( mw.config.get( 'wgPageName' ) ) ), // makes the link
'Random in this category', // text that is displayed
'nav-ric' // html id
);
$('#nav-ric a').attr('target', '_blank'); // opens the link in a new tab
});