User:A. Amritesh/common.js

(function ($) {   'use strict';

mw.loader.using( 'oojs-ui-core' ).done( function {        var totalEdits = 0,            lastYearDate = getLastYearDate,            api = new mw.Api;        api.get( { action: 'query', list: 'usercontribs', ucuser: mw.config.get('wgUserName'), uclimit: 500, ucend: lastYearDate, } ).done( function ( data ) { totalEdits = data.query.usercontribs.length; showGadgetUI; } );

function getLastYearDate { var date = new Date, pastYear = date.getFullYear - 1;

date.setFullYear(pastYear); return date.toISOString; }

function showGadgetUI { var button = new OO.ui.PopupButtonWidget( {               icon: 'menu',                label: 'Your contributions to MediaWiki in the last year',                popup: {                    $content: $( ' You made ' + totalEdits + ' edits  last year! ' ),                   padded: true,                    anchor: false,                    align: 'forwards'                }            } );

$( '#mw-content-text' ).prepend( button.$element ); }

} ); }(jQuery));