User:Pinigin/iplocation.js
(Redirected from User:MaksimPinigin/iplocation.js)
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
Documentation for this user script can be added at User:Pinigin/iplocation. |
/*
* Copyright (c) 2018-2023, Maksim Pinigin
* If user is a anonymous, prints IP location in Special:Contributions, supported languages: English
* To enable this script, go to User:Your_name/common.js and type "importScript('User:Pinigin/iplocation.js');" (without quotes)
* To enable this script on every Wikimedia project, go to meta:User:Your_name/global.js and type: mw.loader.load( "//commons.wikimedia.org/w/index.php?title=User:Pinigin/iplocation.js&action=raw&ctype=text/javascript" );
*/
if(mw.config.values.wgCanonicalSpecialPageName === "Contributions") {
if(mw.config.values.wgRelevantUserName.indexOf('.') !== -1 && mw.config.values.wgRelevantUserName.split('.').length === 4 || mw.config.values.wgRelevantUserName.indexOf(':') !== -1 && mw.config.values.wgRelevantUserName.split(':').length === 8) {
var paiIP = mw.config.values.wgRelevantUserName;
$.ajax({
type: 'GET',
url: 'https://pinig.in/utils/getIPLocation.php',
data: {
ip: paiIP
},
success:function (data) {
if(data.response.country !== "") {
$('#firstHeading').append('<small><small> - ' + data.response.city + ', ' + data.response.region + ", " + data.response.country + " (" + data.response.org + ")</small></small>");
}
}
});
}
}