MediaWiki:Gadget-imageForeignUseCheck.js

if (wgNamespaceNumber == 6) {

$('#filetoc').append('List Foreign Uses'); $('.foreignLink').click(function{

$('.interUses').remove; $('div[id$="linkstoimage"]').append('');

var $interUses = $('.interUses'); var URLsuffix = '.gamepedia.com/api.php?format=json&callback=?';

var langs = { 'Russian':'-ru', 'French':'-fr', 'Polish':'-pl', 'Portuguese':'-pt', 'Korean':'-ko', 'Chinese':'-zhtw' };

var request2 = { action:'query', list:'allimages', ailimit:'1',	aifrom:wgTitle }

$.each(langs, function(key, value) {			var currentLangCode = value;			$.getJSON('http://terraria' + currentLangCode + URLsuffix, request2, function(response2) {

$.each(response2.query.allimages, function(index, value){					if (value.name != wgTitle.replace(/ /g,'_')){

var requestl = { action:'query', list:'imageusage', iutitle:wgPageName };

$.getJSON('http://terraria' + currentLangCode + URLsuffix, requestl, function(response1) {							var currentLangName = key;							if (response1.query.imageusage.length > 0) {								$interUses.append(' ' + currentLangName + ' ');								$.each(response1.query.imageusage, function(index, value) { $interUses.append('' + 										value.title + ''); });							}						});					}				});			});		});		setTimeout(function{$interUses[0].scrollIntoView(true)}, 1000);		setTimeout(function{ if ($interUses.find('li').length < 1){ $interUses.append(' No foreign uses of this image were detected. '); }		}, 1000);	}); }