User:Ainz Ooal Gown/Example-RetrieveUserRights.js

// An example call to mediawiki.api to retrieve rights data of the current user. mw.loader.using('mediawiki.api').then( function { // Api variables and request GET call to mw.api				var api = new mw.Api,			callPromise = api.get({ action: "query", format: "json", list: "users", formatversion: "2", usprop: "rights", ususers: mw.config.get( 'wgUserName' ) }); // When the response is ready, then function	$.when( callPromise, $.ready ).then( function ( results ) { var rightsData, response = results[ 0 ]; if (			response.query &&			response.query.users &&			response.query.users[ 0 ].rights		) { rightsData = response.query.users[ 0 ].rights; //Append the response to the element with "siteNotice" id in text format using jQuery $( '#siteNotice' ).text(rightsData); }	}); });