Forked from mattupham/@mattupham Omegle IP Location Finder
Created
November 7, 2021 04:08
-
-
Save zinetx/afa660008181c12bf6c441450fee5abe to your computer and use it in GitHub Desktop.
@mattupham Omegle IP Location Finder - Ask Questions in our Discord, links below
This file contains 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 characters
// Subscribe on YouTube, and follow on TikTok (@mattupham)! Socials found below: | |
// https://mattupham.com/links | |
// @ me on Discord with any questions! | |
https://link.mattupham.com/discord | |
// -------------------------------------------- | |
// PLEASE REPLACE "your-api-key-here" WITH AN | |
// API KEY FROM https://ipgeolocation.io/ | |
let apiKey = "your-api-key-here"; | |
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(" "); | |
console.log(iceCandidate.candidate); | |
const ip = fields[4]; | |
if (fields[7] === "srflx") { | |
getLocation(ip); | |
} | |
return pc.oaddIceCandidate(iceCandidate, ...rest); | |
}; | |
return pc; | |
}; | |
let getLocation = async (ip) => { | |
let url = `https://api.ipgeolocation.io/ipgeo?apiKey=${apiKey}&ip=${ip}`; | |
await fetch(url).then((response) => | |
response.json().then((json) => { | |
const output = ` | |
--------------------- | |
Country: ${json.country_name} | |
State: ${json.state_prov} | |
City: ${json.city} | |
District: ${json.district} | |
Lat / Long: (${json.latitude}, ${json.longitude}) | |
--------------------- | |
`; | |
console.log(output); | |
}) | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment