MediaWiki:Gadget-emailLinks.js

/* email links *//*
 * BY: U:Technical 13
 * 20 August 2015
 * This Gadget shows all email links placed by T:User if the user has email set up and enabled.

$( '.emailLink' ).each( function{   var checkEmailableUser = $( this ).attr( 'class' ).replace( 'emailLink ',  ).replace( 'email', ); console.info( 'Checking if ' + checkEmailableUser + ' is emailable.' );    $.ajax( {//* REALLY DON'T LIKE THIS!!! *//*     url: 'http://ddowiki.com/api.php?' + 'action=query' + '&format=json' + '&list=users' + '&usprop=emailable' + '&ususers=' + encodeURIComponent( checkEmailableUser ), dataType: 'json', success: function( userData ) { var isEmailable = ( userData.query.users[ 0 ].emailable !== undefined ? true : false ); console.info( 'Found out that ' + checkEmailableUser + ' is ' + ( isEmailable ? '' : 'not ' ) + 'emailable.' ); if ( isEmailable ) { $( '.email' + checkEmailableUser ).show; }     },      fail: function( failureData ) { alert( 'Sorry, failed to retrieve information from API.\n'         + 'Please check the console for more details if available.' ); console.error( '%O', failureData ); }   } ); } );