MediaWiki:Gadget-ipInfo.js

// By Equazcion: http://terraria.gamepedia.com/User:Equazcion

if (mw.config.get( 'wgCanonicalSpecialPageName' ) == 'Contributions') {

var wgRelevantUserName = mw.config.get( 'wgRelevantUserName' );

if (typeof wgRelevantUserName !== 'undefined' && !isNaN(wgRelevantUserName.substr(0,1))){ var torLinkTitle = 'Check if this IP is a TOR node'; var mapLinkTitle = 'Map these coordinates on Google'; var torLink = ' (tor check) '; var ipInfoField = ' IP info '; var $contentSub = $('.mw-contributions-form'); $contentSub.after(ipInfoField); var $ipInfo = $('.ipInfo'); var skip = 0;

$.getJSON('https://ipinfo.io/' + wgRelevantUserName + '/json', function(ipdata){			$.each(ipdata, function(key, data){ skip = 0; key = key.substr(0,1).toUpperCase + key.slice(1); switch (key) { case 'Ip': data += ' ' + torLink; key = 'IP'; break; case 'Loc': data += ' (map) '; break; case 'Readme': skip = 1; break; }				if (skip == 0) $ipInfo.append(' ' + key + ':  ' + data + '  '); });		});	} }