User:PrimeHunter/Base title.js

/* If the page name ends in a parenthetical part after a space then this script makes a "Base title" link under "Tools" in the sidebar. The link goes to the page name without the parenthetical part. To use the script, add the following line to Special:MyPage/common.js: importScript('User:PrimeHunter/Base title.js'); // Linkback: User:PrimeHunter/Base title.js



$( document ).ready( function { var pattern = /_\(.*\)$/;  if (mw.config.get('wgPageName').search(pattern) > 0) {    mw.util.addPortletLink( 'p-tb', mw.util.getUrl( mw.config.get('wgPageName').replace(pattern,'') ), 'Base title', 't-basetitle', 'Title without parenthetical part: ' + mw.config.get('wgPageName').replace(pattern,'').replace('_',' '), null, '#t-info' ); } });