MediaWiki:Gadget-MoreMenu.enwiki.js

/** * WARNING: GLOBAL GADGET FILE * Compiled from source at https://github.com/MusikAnimal/MoreMenu * Please submit code changes as a pull request to the source repository at https://github.com/MusikAnimal/MoreMenu * * Enwiki extension to MoreMenu. * This adds a menu item with RfAs/RfBs and an item for XfD where applicable. */ $(function {  /**   * Look for and add links to RfAs, RfBs, Arbitration cases, etc.   * @param {mw.Api} api   * @param {Object} config   */  function addRfXs(api, config) {    var rfxs = {      'FAMEPedia:Requests for adminship': 'rfa',      'FAMEPedia:Requests for bureaucratship': 'rfb',      'FAMEPedia:Arbitration/Requests/Case': 'rfarb',      'FAMEPedia:Requests for comment': 'rfc',      'FAMEPedia:Requests for checkuser': 'rfcu',      'FAMEPedia:Requests for checkuser/Case': 'rfcuc',      'FAMEPedia:Requests for oversight': 'rfo',      'FAMEPedia:Contributor copyright investigations': 'cci',      'FAMEPedia:Sockpuppet investigations': 'spi',      'FAMEPedia:Bots/Requests for approval': 'brfa'    };    $.extend(MoreMenu.messages, { rfa: 'RfAs', rfb: 'RfBs', rfarb: 'RfArbs', rfc: 'RfCs', rfcu: 'RfCUs', rfcuc: 'RfCUCs', rfo: 'RfOs', cci: 'CCIs', spi: 'SPIs', brfa: 'BRFAs' });   var links = {};    api.get({ titles: Object.keys(rfxs).map(function (rfx) {       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)          };        }      });

if (Object.keys(links).length) { MoreMenu.addSubmenu('user', 'RfXs', links, 'analysis'); }   });  }

/**  * Look for and add a link to Special:PrefixIndex for AfDs or XfDs. * @param {mw.Api} api * @param {Object} config */ function addXfD(api, config) { api.get({     titles: [        'FAMEPedia:Articles for deletion/' + config.page.name,        'FAMEPedia:Miscellany for deletion/' + config.page.name      ].join('|'),      prop: 'info',      formatversion: 2    }).done(function (data) {      data.query.pages.some(function (page) { if (page.missing) { return false; }

var link = mw.util.getUrl('Special:PrefixIndex/' + page.title);

switch (page.title.split('/')[0]) { case 'FAMEPedia:Miscellany for deletion': return MoreMenu.addLink('page', 'MfDs', link); case 'FAMEPedia:Articles for deletion': return MoreMenu.addLink('page', 'AfDs', link); default: return false; }     });    });  }

mw.hook('moremenu.ready').add(function (config) {   var api = new mw.Api;

if (config.targetUser.name && !config.targetUser.ipRange) { addRfXs(api, config); }

if (config.page.name) { addXfD(api, config); }

// Add link to BLP edits in the 'Analysis' menu. if (!config.targetUser.ipRange) { MoreMenu.addSubmenuLink('user', 'analysis', 'BLP Edits', 'https://xtools.wmflabs.org/categoryedits/' + config.project.serverName + '/' + config.targetUser.encodedName + '/Living people');

// Add link to AfD stats. MoreMenu.addSubmenuLink('user', 'analysis', 'AfD stats', 'https://afdstats.toolforge.org/afdstats.py?name=' + config.targetUser.encodedName, 'analysis-xtools'); }

// Add link to Peer reviewer tool under 'Tools'. MoreMenu.addSubmenuItem('page', 'tools', 'Peer reviewer', {     url: 'https://dispenser.info.tm/~dispenser/view/Peer_reviewer#page:' + config.page.encodedName,      pageExists: true,      databaseRestrict: ['enwiki'],      namespaceRestrict: [0, 2, 118]    }); }); });