User:Euphoria/common.js: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
No edit summary |
No edit summary |
||
Line 2: | Line 2: | ||
mw.loader.using(['mediawiki.util']) |
mw.loader.using(['mediawiki.util']) |
||
.then(function () { |
.then(function () { |
||
// |
// Extract the username from the current page title |
||
var |
var pageTitle = mw.config.get('wgTitle'); |
||
var username = pageTitle.split('/')[0]; |
|||
mw.config.get('wgCanonicalSpecialPageName') === 'Log' || |
|||
mw.config.get('wgCanonicalSpecialPageName') === 'Contributions' || |
|||
⚫ | |||
⚫ | |||
// |
// Check if the current page is a user page or talk page |
||
⚫ | |||
if (isUserRelatedPage) { |
|||
⚫ | |||
// 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.util.getUrl('Special:CentralAuth/' + username), |
||
'SUL', |
'SUL', |
||
'ca-sul', |
'ca-sul', |
Revision as of 07:04, 10 November 2023
// Load necessary module asynchronously
mw.loader.using(['mediawiki.util'])
.then(function () {
// Extract the username from the current page title
var pageTitle = mw.config.get('wgTitle');
var username = pageTitle.split('/')[0];
// Check if the current page is a user page or talk page
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(
'p-cactions',
mw.util.getUrl('Special:CentralAuth/' + username),
'SUL',
'ca-sul',
'SUL',
null,
'#ca-sul'
);
}
});