MediaWiki:PseudoTalkPages/code.js

//PseudoTalkPages - Count of Howard //Inspiration courtesy of User:Ursuul and the Diep.io community //24-01-17 - Initial revision

$(function {   var mwVariables = mw.config.get([ 'wgPageName', 'wgUserLanguage', 'wgNamespaceNumber' ]),   i18n = {        'en': {            tabTitle: 'Talk Page',            backButton: 'Back to Message Wall',            newMessage: 'Leave message',            edit: 'Edit'        }    },    lang = mwVariables.wgUserLanguage,    textContent = i18n.hasOwnProperty(lang) ? i18n[lang] : i18n.en,    tabsList = $('ul.tabs > li'),    menuList = $('.wikia-menu-button ul'),    namespaces = [2, 1200, 500, -1],    href = $('a[data-id="edit"]').attr('href'),    editAction = '?action=edit',    sectionAction = '&section=new',    content = $('.UserProfileMasthead .masthead-info h1').html;    content = mw.util.wikiUrlencode(content);    //Assorted elements    var talkPageTab = mw.html.element('li', { 'data-id': 'talkpage', id: 'talkpage' });

var talkPageTabLink = mw.html.element('a', {       href: '/wiki/User:' + content + '/Talk',    }, textContent.tabTitle);

var sprite = mw.html.element('img', {       class: 'sprite edit-pencil',        height: 16,        width: 22,        src: 'data:image/gif;base64,R0lGODlhAQABAIABAAAAAP///yH5BAEAAAEALAAAAAABAAEAQAICTAEAOw%3D%3D'    }, ' ' + textContent.newMessage + ' ');

//Placement of Talk tab after Message Wall tab if( $.inArray(mwVariables.wgNamespaceNumber, namespaces) != -1) { $(tabsList[1]).after(talkPageTab); $(talkPageTabLink).appendTo('#talkpage'); } else { return; }

if (mwVariables.wgNamespaceNumber === 2 && mwVariables.wgPageName.split('/')[1] === 'Talk') { mw.util.addCSS(           '.wikia-menu-button img.sprite.edit-pencil {' +                'background-position: -1058px -48px;' +            '}' +            '.WikiaPageHeader .wikia-menu-button {' +                'float:right;' +            '}' +            '.wikinav2 .WikiaPageHeader > .comments {' +                'margin: 2px 0 0;' +            '}'        );

$('' + textContent.edit + '').prependTo(menuList); $('a[data-id="comment"]').html(textContent.backButton); $('a[data-id="edit"]').html(sprite); $('a[data-id="edit"]').attr('href', href + sectionAction); } else { return; } });