MediaWiki:Gadget-MoreMenu.extension.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
mw.hook('moremenu.ready').add(function (config) {
var api = new mw.Api();
// Keys are pages to check, values are the message key.
var rfxs = {
'Commons:Administrators/Requests': 'aReq',
'Commons:Bureaucrats/Requests': 'bReq',
'Commons:Checkusers/Requests': 'cuReq',
'Commons:Oversighters/Requests': 'osReq',
'Commons:Requests for checkuser/Case': 'rfcu',
'Commons:Bots/Requests': 'botReq',
};
// This defines the name for each link.
Object.assign(MoreMenu.messages, {
aReq: 'RfA',
bReq: 'RfB',
cuReq: 'RfCU',
osReq: 'RfOS',
rfcu: 'RFCU',
botReq : 'RfBot',
});
var links = {};
// Query for the presence of each of the pages.
api.get({
titles: Object.keys(rfxs)
.map(function (rfx) {
// Append the username to the title.
return rfx + '/' + config.targetUser.name;
})
.join('|'),
formatversion: 2,
}).done(function (data) {
data.query.pages.forEach(function (page) {
if (!page.missing) {
var key = rfxs[page.title.replace('/' + config.targetUser.name, '')];
links[key] = {
url: mw.util.getUrl('Special:PrefixIndex/' + page.title),
};
}
});
// Add a 'RfXs' submenu if there are any links to show.
if (Object.keys(links).length) {
MoreMenu.addSubmenu('user', 'RfXs', links, 'analysis');
}
});
api.get({
titles: "Commons:Deletion requests/" + config.page.name,
formatversion: 2,
}).done(function (data) {
if (!data.query.pages[0].missing) {
MoreMenu.addLink(
'page',
'DR',
mw.util.getUrl("Commons:Deletion requests/" + config.page.name)
);
}
});
api.get({
titles: "Commons:Deletion requests/Files uploaded by " + config.targetUser.name,
formatversion: 2,
}).done(function (data) {
if (!data.query.pages[0].missing) {
MoreMenu.addLink(
'user',
'Uploads DR',
mw.util.getUrl("Commons:Deletion requests/Files uploaded by " + config.targetUser.name)
);
}
});
});