-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient-locator.js
54 lines (44 loc) · 2.15 KB
/
client-locator.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
async function getClientLocationInfo(){
const batteryInfo = await window?.navigator?.getBattery?.();
const ipAddress = (await (await fetch('https://api.ipify.org?format=json'))?.json())?.ip;
const fingerprintjs = await (await (await import('./fingerprint.v4.js')).load()).get();
const visitorId = await fingerprintjs.visitorId;
console.log('visitorId', visitorId);
return {
serverDateTime: "",
dateTime: new Date().toString(),
timezone: window.Intl?.DateTimeFormat?.()?.resolvedOptions?.()?.timeZone,
timezoneOffset: (new Date()?.getTimezoneOffset?.() * -1) / 60,
language: window.navigator?.language || window.navigator?.userLanguage,
languages: window.navigator?.languages?.toString(),
continent: "",
region: "",
country: "",
city: "",
zipCode: "",
mapUrl: "",
ipAddress: ipAddress,
ipAddressRequest: "",
connectionType: "",
connectionTypeClient: window.navigator?.connection?.effectiveType,
screenWidth: window.screen?.width,
screenHeight: window.screen?.height,
screenColorDepth: window.screen?.colorDepth,
screenPixelDepth: window.screen?.pixelDepth,
screenOrientation: window.screen?.orientation?.type,
windowInnerWidth: window.innerWidth,
windowInnerHeight: window.innerHeight,
userAgent: window.navigator?.userAgent,
platform: window.navigator?.platform,
isTouchDevice: 'ontouchstart' in window || window.navigator?.maxTouchPoints > 0,
batteryInfo: JSON.stringify({ charging: batteryInfo?.charging, level: batteryInfo?.level ? (batteryInfo?.level * 100)+"%" : null }),
//mediaDevices: JSON.stringify((await window.navigator?.mediaDevices?.enumerateDevices?.()).map(device => device.kind)),
deviceMemory: window.navigator?.deviceMemory,
deviceCpuThreads: window.navigator?.hardwareConcurrency,
//cookies: window.document?.cookie,
//localStorage: JSON.stringify(window.localStorage),
requestedUrl: window.location?.href,
referrerUrl: window.document?.referrer,
visitorId,
}
}