MediaWiki:Gadget-talkbutton.js

// Talk page button // Created by Lil' Miss Rarity // MIT OS License $(function {   var config = mw.config.get([ 'skin', 'wgFormattedNamespaces', 'wgNamespaceNumber', 'wgPageName' ]);

if (config.wgNamespaceNumber !== 0 || config.skin !== 'oasis' || window.TalkButtonLoaded) { return; }   window.TalkButtonLoaded = true;

$.get(mw.util.wikiScript('api'), {       action: 'query',        format: 'json',        meta: 'allmessages',        ammessages: 'oasis-page-header-talk'    }, function(d) {        var talkMessage = d.query.allmessages[0]['*'];

$('.page-header__contribution-buttons').append(           $('')                .attr({ accesskey: 't', class: 'wds-button wds-is-secondary wds-is-squished TalkButtonBubble', href: '/wiki/Talk:' + config.wgPageName })               .text(talkMessage)        );

$.ajax({           type: 'GET',            url: mw.util.wikiScript('api'),            data: {                titles: config.wgFormattedNamespaces[1] + ':' + config.wgPageName,                action: 'query',                format: 'json',                prop: 'info',                inprop: 'revcount'            }        }).always(function(data) {            var pageData = data.query && data.query.pages[Object.keys(data.query.pages)[0]];            $('.TalkButtonBubble').text(talkMessage + ' (' + (pageData && pageData.revcount || 0) + ')');        }); }); });