MediaWiki:UserActivityTab/code.js

/* * UserActivityTab - Count of Howard * 31-01-17 - Initial revision */ $(function {   var mwV = mw.config.get([ 'wgSiteName', 'wgPageName', 'wgUserName', 'wgUserLanguage', 'wgNamespaceNumber', 'wgArticlePath' ]);

if (mwV.wgSiteName === 'Community Central') { return; }

var i18n = { 'en': 'User Activity', 'sv': 'Användaraktivitet' },   i18n = i18n.hasOwnProperty(mwV.wgUserLanguage) ? i18n[mwV.wgUserLanguage] : i18n.en, namespaces = [2, 3, 1200, 500, -1], //Profile, talk page, message wall, blog, contribs uaTab = mw.html.element('li', {       'data-id': 'user-activity'    }), uaTabLink = mw.html.element('a', {       href: 'http://community.wikia.com' + mwV.wgArticlePath.replace('$1', 'Special:UserActivity'),        title: 'Special:UserActivity'    }, i18n); //Janked way to check if the page is a user page and if the userpage belongs to the script user if ($.inArray(mwV.wgNamespaceNumber, namespaces) !== -1 && mwV.wgPageName.split(/[\/:]+/).pop === mw.util.wikiUrlencode(mwV.wgUserName)) { $(uaTab).appendTo('ul.tabs'); $(uaTabLink).appendTo('li[data-id="user-activity"]'); } });