Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
(asyncfunction($,mw){'use strict';if((mw.config.get('wgNamespaceNumber')===mw.config.get('wgNamespaceIds').user&&mw.config.get('wgTitle')==='GeneralNotability/SpurLookup')&&mw.config.get('wgAction')==='view'){awaitmw.loader.load(['mediawiki.util','mediawiki.user']);constcontentdiv=document.getElementById('spur-content');contentdiv.textContent='';// clear childrenconstnoScriptDiv=document.getElementById('spur-noscript');noScriptDiv.textContent='';// nuke the "you don't have the script" warningconstip=mw.util.getParamValue('address');if(!ip){contentdiv.innerText='Address parameter was not specified in the URL';return;}if(!mw.util.isIPAddress(ip)){contentdiv.innerText=`${ip} is not a valid IP address`;return;}mw.config.set("wgRelevantUserName",ip);letapiKey=mw.user.options.get('userjs-spurkey');if(!apiKey){constmwapi=newmw.Api();apiKey=prompt('Please enter your Spur API key');if(!apiKey){contentdiv.innerText='An API key is required to use this tool';return;}mw.user.options.set('userjs-spurkey',apiKey);awaitmwapi.saveOption('userjs-spurkey',apiKey);}// Actually send the queryconstapiUrl=`https://api.spur.us/v1/context/${ip}`;letapiResponse;try{apiResponse=$.ajax({async:false,url:apiUrl,headers:{'Token':apiKey},dataType:'json'});}catch(err){contentdiv.innerText=`Failed to query the Spur API: ${err}`;return;}console.log(apiResponse);constresponseJson=apiResponse.responseJSON;letnewHtml='';newHtml+=`This search took ${apiResponse.getResponseHeader('x-query-cost')} queries.<p/>`;newHtml+=`You have ${apiResponse.getResponseHeader('x-balance-remaining')} queries left this month.<p/>`;newHtml+=`<ul> <li>IP: <a href="${mw.config.get('wgServer')}${mw.config.get('wgArticlePath').replace('$1','Special:Contributions/')}${responseJson.ip}">${responseJson.ip}</a></li> <li>Suspected VPN/proxy: ${responseJson.anonymous}</li> <li><a href="https://isprangefinder.toolforge.org/hint.php?type=asn&range=${responseJson.as.number}">AS${responseJson.as.number}</a>, belongs to ${responseJson.as.organization}</li>`;if(responseJson.assignment.exists){newHtml+=` <li>Assignment: ${responseJson.assignment}</li>\n`;}if(responseJson.infrastructure){newHtml+=` <li>Infrastructure: ${responseJson.infrastructure}</li>\n`;}if(responseJson.devices&&responseJson.devices.estimate){newHtml+=` <li># devices on IP (estimated): ${responseJson.devices.estimate}</li>\n`;}if(responseJson.vpnOperators.exists){newHtml+=' <li>VPN operators:\n';newHtml+=' <ul>';for(constoperofresponseJson.vpnOperators.operators){newHtml+=` <li>${oper.name}</li>\n`;}newHtml+=' </ul>\n </li>\n';}if(responseJson.geolite){newHtml+=` <li>GeoLite data: ${JSON.stringify(responseJson.geolite)}</li>\n`;}if(responseJson.deviceBehaviors.exists){newHtml+=' <li>Device behaviors:\n';newHtml+=' <ul>';for(constbehaviorofresponseJson.deviceBehaviors.behaviors){newHtml+=` <li>${JSON.stringify(behavior.name)}</li>\n`;}newHtml+=' </ul>\n </li>\n';}if(responseJson.proxiedTraffic.exists){newHtml+=' <li>Proxy services:\n';newHtml+=' <ul>';for(constproxyofresponseJson.proxiedTraffic.proxies){newHtml+=` <li>${JSON.stringify(proxy)}</li>\n`;}newHtml+=' </ul>\n </li>\n';}if(responseJson.geoPrecision.exists){newHtml+=` <li>Estimated user location: ${JSON.stringify(responseJson.geoPrecision)}</li>\n`;}if(responseJson.similarIPs.exists){newHtml+=' <li>Similar IPs:\n';newHtml+=' <ul>';for(constipofresponseJson.similarIPs.ips){newHtml+=` <li><a href="${mw.config.get('wgServer')}${mw.config.get('wgArticlePath').replace('$1','Special:Contributions/')}${ip}">${ip}</a> (<a href="https://en.wikipedia.org/wiki/User:GeneralNotability/SpurLookup?address=${ip}">query</a>)</li>\n`;}newHtml+=' </ul>\n </li>\n';}if(responseJson.wifi.exists){newHtml+=' <li>Associated SSIDs:\n';newHtml+=' <ul>';for(constwifiofresponseJson.wifi.ssids){newHtml+=` <li>${wifi}</li>\n`;}newHtml+=' </ul>\n </li>\n';}newHtml+='</ul>';contentdiv.innerHTML=newHtml;}})(jQuery,mediaWiki);