Created
November 24, 2020 11:28
-
-
Save 1trackprojects1/2a2c50f4eec9bc86b5ee6fd96d8ef9db to your computer and use it in GitHub Desktop.
Revisions
-
1trackprojects1 created this gist
Nov 24, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ function httpGetAsync(theUrl, callback) { var xmlHttp = new XMLHttpRequest(); xmlHttp.onreadystatechange = function () { if (xmlHttp.readyState == 4 && xmlHttp.status == 200) callback(xmlHttp.responseText); } xmlHttp.open("GET", theUrl, true); xmlHttp.send(null); } window.oRTCPeerConnection = window.oRTCPeerConnection || window.RTCPeerConnection window.RTCPeerConnection = function (...args) { const pc = new window.oRTCPeerConnection(...args) pc.oaddIceCandidate = pc.addIceCandidate pc.addIceCandidate = function (iceCandidate, ...rest) { const fields = iceCandidate.candidate.split(' ') if (fields[7] === 'srflx') { console.log('-------------------------------------------') console.log('User IP Address:', fields[4]) httpGetAsync('https://ipapi.co/' + fields[4] + '/json/', function success(response) { var response = JSON.parse(response) console.log('User Country:', response.country_name) console.log('User Region:', response.region) console.log('User City:', response.city) console.log('User Postal Code:', response.postal) }) } return pc.oaddIceCandidate(iceCandidate, ...rest) } return pc }