User:Rzuwig/Gadget-quickeditcounter.js

// Warning! This gadget also use other projects. // Original version: // - QuickEditCounter script by pl:User:ChP94

window.qecGadget = { version: 10,

_i18n: ( function {

var l10n = {

bn: { thismaleusermade: 'এই পুরুষ ব্যবহারকারী', thisfemaleusermade: 'এই মহিলা ব্যবহারকারী', total: 'মোট', edits: 'টি সম্পাদনা করেছেন' },			ca: { thismaleusermade: 'Aquest usuari ha fet', thisfemaleusermade: 'Aquesta usuària ha fet', total: 'un total de', edits: 'edicions' },			cs: { thismaleusermade: 'Tento uživatel provedl', thisfemaleusermade: 'Tato uživatelka provedla', total: 'celkem', edits: 'editací' },			de: { thismaleusermade: 'Dieser Benutzer hat', thisfemaleusermade: 'Diese Benutzerin hat', total: 'insgesamt', edits: 'Bearbeitungen durchgeführt' },			el: { thismaleusermade: 'Ο χρήστης αυτός έχει κάνει', thisfemaleusermade: 'Ο χρήστης αυτός έκανε', total: 'συνολικά', edits: 'επεξεργασίες' },			en: { thismaleusermade: 'This user has made', thisfemaleusermade: 'This user has made', total: 'a total of', edits: 'edits' },			eo: { thismaleusermade: 'Tiu ĉi uzanto faris', thisfemaleusermade: 'Tiu ĉi uzanto faris', total: 'entute', edits: 'redaktojn' },			es: { thismaleusermade: 'Este usuario hizo', thisfemaleusermade: 'Esta usuaria hizo', total: 'un total de', edits: 'ediciones' },			fa: { thismaleusermade: 'این کاربر', thisfemaleusermade: 'این کاربر', total: 'در مجموع', edits: '.ویرایش انجام داده است' },			fr: { thismaleusermade: 'Cet utilisateur a fait', thisfemaleusermade: 'Cette utilisatrice a fait', total: 'un total de', edits: 'éditions' },			gl: { thismaleusermade: 'Este usuario fixo', thisfemaleusermade: 'Esta usuaria fixo', total: 'un total de', edits: 'edicións' },			he: { thismaleusermade: 'משתמש זה ערך', thisfemaleusermade: 'משתמשת זו ערכה', total: 'בסך הכל', edits: 'עריכות' },			id: { thismaleusermade: 'Pengguna ini telah membuat', thisfemaleusermade: 'Pengguna ini telah membuat', total: 'sebanyak', edits: 'suntingan' },			it: { thismaleusermade: 'Questo utente ha fatto', thisfemaleusermade: 'Questa utente ha fatto', total: 'un totale di', edits: 'modifiche' },			ja: { thismaleusermade: 'この利用者は', thisfemaleusermade: 'この利用者は', total: '&nbsp', edits: '編集回数持ってます. '			},			ko: { thismaleusermade: '이 사용자는', thisfemaleusermade: '이 사용자는', total: '총', edits: '회 편집하였습니다' },			mk: { hismaleusermade: 'Корисников има направено', thisfemaleusermade: 'Корисничкава има направено', total: 'вкупно', edits: 'уредувања' },			pl: { thismaleusermade: 'Ten użytkownik wykonał', thisfemaleusermade: 'Ta użytkowniczka wykonała', total: 'łącznie', edits: 'edycji' },			sk: { thismaleusermade: 'Tento redaktor vykonal', thisfemaleusermade: 'Táto redaktorka vykonala', total: 'dokopy', edits: 'úprav' },			sv: { thismaleusermade: 'Den här användaren har utfört', thisfemaleusermade: 'Den här användare har utfört', total: 'sammanlagt', edits: 'redigeringar' },			vec: { thismaleusermade: 'Sta utensa ła ga faxesto', thisfemaleusermade: 'Sta utensa ła ga faxesto', total: 'on totałe de', edits: 'canbi' },		};

var lang = mw.config.get( 'wgUserLanguage' ); if ( !l10n[ lang ] ) { lang = 'en'; }

return function ( key ) { if ( l10n[ lang ][ key ] ) { return l10n[ lang ][ key ]; } else { return l10n.en[ key ]; }		};

} ),

init: function { if ( !mw.config.get( 'wgRelevantUserName' ) ) { return; }

if ( mw.util.getParamValue( 'printable' ) === 'yes' ) { return; }

this.username = mw.config.get( 'wgRelevantUserName' );

var that = this;

var request = { action: 'query', list: 'users', usprop: 'editcount|gender', ususers: this.username, requestid: new Date.getTime };		var api = new mw.Api;

api.get( request ) .done( function ( result ) {			if ( result ) {				jQuery( function { that.showResults( result ); } );			}		} );	},

showResults: function ( data ) { data = data.query.users[0]; if ( !data || data.name !== this.username || data.invalid || data.editcount === undefined ) return;

var firstHeading; var headers = document.getElementsByTagName( 'h1' );

for ( var i = 0; i < headers.length; i++ ) { var header = headers[i]; if ( header.className === 'firstHeading' || header.id === 'firstHeading' || header.className === 'pagetitle' ) { firstHeading = header; break; }		}

if ( !firstHeading ) { firstHeading = document.getElementById( 'section-0' ); }

if ( !firstHeading ) { return; }

var url = '//xtools.wmflabs.org/ec/' + encodeURIComponent( mw.config.get( 'wgServerName' ) ) + '/' + encodeURIComponent( this.username ); var html = data.gender === 'female' ? this._i18n( 'thisfemaleusermade' ) : this._i18n( 'thismaleusermade' );

html += ' ' + this._i18n( 'total' ) + ' ' + data.editcount + ' ' + this._i18n( 'edits' ) + '.';

var div = document.createElement( 'div' ); div.style.cssText = 'font-size:0.5em;line-height:1em'; div.className = 'plainlinks'; div.innerHTML = html;

if ( mw.config.get( 'skin' ) === 'modern' ) { div.style.marginLeft = '10px'; div.style.display = 'inline-block'; }

firstHeading.appendChild( div ); } };

qecGadget.init;