User:MarkAHershberger/common.js

function ExtractInterwikiMapTable { $.getJSON(wgScriptPath + '/api.php?action=query&meta=siteinfo&siprop=interwikimap&format=json', function(data) {		var iw_prefix, iw_url, iw_local, iw_api, re_escape = /(')/g, result = ;		for (var i = 0, iwm = data.query.interwikimap; i < iwm.length; i++) {			iw_prefix = "'" + iwm[i].prefix.replace(re_escape, '\\$1') + "'";			iw_url = "'" + iwm[i].url.replace(re_escape, '\\$1') + "'";			iw_local = (typeof iwm[i].local == 'string') ? '1' : '0';			iw_api = "'" + (iwm[i].iw_api || ).replace(re_escape, '\\$1') + "'";			result += 'INSERT INTO interwiki (iw_prefix, iw_url, iw_local, iw_trans, iw_api) VALUES ('+iw_prefix+', '+iw_url+', '+iw_local+', 0, '+iw_api+');\n'		}		$('').val(result).appendTo(document.body);	}); } /* $(ExtractInterwikiMapTable); */