User:Euphoria/common.js: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 2: Line 2:
mw.loader.using(['mediawiki.util'])
mw.loader.using(['mediawiki.util'])
     .then(function () {
     .then(function () {
         // Check if the current page is associated with the user
         // Extract the username from the current page title
         var isUserRelatedPage = mw.config.get('wgCanonicalSpecialPageName') === 'CentralAuth' ||
         var pageTitle = mw.config.get('wgTitle');
                                mw.config.get('wgCanonicalSpecialPageName') === 'Log' ||
        var username = pageTitle.split('/')[0];
                                mw.config.get('wgCanonicalSpecialPageName') === 'Contributions' ||
                                mw.config.get('wgNamespaceNumber') === 2 || // User namespace
                                mw.config.get('wgNamespaceNumber') === 3; // User talk namespace


         // If the current page is associated with the user, add the "SUL" link
        // Check if the current page is a user page or talk page
         if (isUserRelatedPage) {
        var isUserPage = mw.config.get('wgNamespaceNumber') === 2; // User namespace
        var isTalkPage = mw.config.get('wgNamespaceNumber') === 3; // User talk namespace
 
         // If the current page is a user page or talk page, add the "SUL" link with the extracted username
         if (isUserPage || isTalkPage) {
             var sulLink = mw.util.addPortletLink(
             var sulLink = mw.util.addPortletLink(
                 'p-cactions',
                 'p-cactions',
                 mw.util.getUrl('Special:CentralAuth/' + mw.user.getName()),
                 mw.util.getUrl('Special:CentralAuth/' + username),
                 'SUL',
                 'SUL',
                 'ca-sul',
                 'ca-sul',
152

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu