Created
February 5, 2020 17:36
-
-
Save aranajhonny/dadf28964f990a810ebf561ceefa40df to your computer and use it in GitHub Desktop.
detect if are using vpn
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 characters
function detectVPN() { | |
var browserTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone | |
return fetch(`https://ipapi.co/json`) | |
.then(function(response) { return response.json() }) | |
.then(function (data) { | |
var ipTimezone = data.timezone | |
console.log(`browser timezone: ${browserTimezone}`, `ip timezone: ${ipTimezone}`) | |
return { | |
browser: browserTimezone, | |
ip: ipTimezone, | |
usingVPN: ipTimezone != browserTimezone | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment