User:Sam Sailor/Scripts/Base title.js

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.
// Forked from https://en.wikipedia.org/wiki/User:PrimeHunter/Base_title.js

$( document ).ready( function() {
    var parentheticalPattern = /_\(.*\)$/;
    var commaPattern = /,.*$/;
    var compositePattern = new RegExp(parentheticalPattern.source + '|' + commaPattern.source);
    var wgPageName = mw.config.get('wgPageName');

    if (wgPageName.search(compositePattern) > -1) {

        var baseTitle = wgPageName.replace(compositePattern, '');

        mw.util.addPortletLink(
            'p-navigation',
            mw.util.getUrl( baseTitle ),
            'Base title',
            't-basetitle',
            'Title without disambiguation part: ' + baseTitle.replace(/_/g, ' '),
            null,
            '#t-info'
        );
    }
});