User:Jafeluv/ContribsTabVector.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.
/*
This script adds Contributions and Statistics tabs to User and User talk pages. For Vector skin.
Stolen from User:Equazcion and used shamelessly under CC-BY-SA.
Original documentation: http://en.wikipedia.org/wiki/User:Equazcion/ContribsTabVector
*/
// Get wiki-specific information
if(mw.config.exists('wgServer')) {
var server = mw.config.get('wgServer');
var langCode = server.substring(2, server.indexOf('.', 2));
var wikiCode = server.substring(2 + langCode.length + 1, server.indexOf('.org'));
}
function addContribTools(username, omitContribs) {
var contribsTabName = "Contr";
var centralAuthTabName = "CAuth";
var luxoTabName = "Luxo";
// Grab leftmost tab
var contribsTabMain = $('#left-navigation li').slice(0,1).css('opacity','0.9');
// Contributions tab
var tabContribs = contribsTabMain.clone(true).attr('id', contribsTabMain.attr('id')+'-').css('opacity','0.9').removeClass('new').removeClass('selected');
var contribsTabURL = '//' + langCode + '.' + wikiCode + '.org/wiki/Special:Contributions/' + username;
tabContribs.find('a').attr('href', contribsTabURL).empty().text(contribsTabName).attr('title', "Show this user's contributions");
// CentralAuth tab
var centralAuthTab = contribsTabMain.clone(true).attr('id', contribsTabMain.attr('id')+'-').css('opacity','0.9').removeClass('new').removeClass('selected');
var centralAuthTabURL = '//meta.wikimedia.org/wiki/Special:CentralAuth/' + username;
centralAuthTab.find('a').attr('href', centralAuthTabURL).empty().text(centralAuthTabName).attr('title', "Show this user's CentralAuth info");
// Luxo tab
var luxoTab = contribsTabMain.clone(true).attr('id', contribsTabMain.attr('id')+'-').css('opacity','0.9').removeClass('new').removeClass('selected');
var luxoTabURL = 'http://tools.wmflabs.org/guc/index.php?user=' + username;
luxoTab.find('a').attr('href', luxoTabURL).empty().text(luxoTabName).attr('title', "Show this user's global contributions");
// Place constructed tabs before the first right-hand tab (done here for easy ordering)
var lefts = $('#left-navigation li');
luxoTab.insertAfter(lefts[lefts.length-1]);
if(!omitContribs) tabContribs.insertBefore(luxoTab);
centralAuthTab.insertBefore(luxoTab);
// Add less often needed contribution tools to sidebar toolbox.
mw.util.addPortletLink('p-tb', 'http://tools.wmflabs.org/xtools/pcount/index.php?name=' + username + '&lang=' + langCode + '&wiki=' + wikiCode, 'X!\'s tool', 't-soxred', 'X!\'s tool', '', document.getElementById('t-log'));
mw.util.addPortletLink('p-tb', 'http://toolserver.org/~krinkle/MoreContributions/index.php?username=' + username + '&allwikis=on', 'MoreContributions', 't-krinkle','MoreContributions', '', document.getElementById('t-soxred'));
}
if(mw.config.get('wgCanonicalNamespace') == 'User' || mw.config.get('wgCanonicalNamespace') == 'User_talk') {
addContribTools(wgTitle.split("/")[0], false);
}
if(mw.config.get('wgCanonicalSpecialPageName') == 'Contributions' && document.getElementsByName('target').length > 0) {
addContribTools(document.getElementsByName('target')[0].value, true);
}