MediaWiki:User Avatar Finder/code.js

// --- // @name        User Avatar Finder // @version     1.0 // @description Finds and adds the avatar image of a user into a template // @author      Static Whisper // ---   'use strict'; $('#WikiaPage div.UserAvatarFetch').each(function {       var userText = $('.avi-thisUsername', this).text;        var aviSize = $('.avi-thisSize', this).text;        var $foundDiv = $(this);        var getAvi;        var parseRequest;        if (userText !== '') {            var request = $.get('/api/v1/User/Details?ids=' + userText.replace(/\s/g, '+'))            .done(function { if (request.statusText !== 'Not Found') { parseRequest = JSON.parse(request.responseText); if ((aviSize === '') || (isNaN(aviSize))) getAvi = parseRequest.items[0].avatar; else { if (parseInt(aviSize, 10) > 150) aviSize = '150'; else if (16 > parseInt(aviSize, 10)) aviSize = '16'; getAvi = parseRequest.items[0].avatar.replace('\/scale-to-width-down\/100', '\/scale-to-width-down\/' + aviSize); }                     $foundDiv.empty; $foundDiv.append(''); }           })            .fail(function { console.log('Requested user \'' + userText + '\', but user does not exist.'); });       }    }); });
 * (function {