forked from longouyang/even-odd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fingerprint1.js
35 lines (25 loc) · 923 Bytes
/
fingerprint1.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
/* global turk, store, location */
var fingerprint;
function setGeo(data) {
fingerprint.ip = data.ip;
fingerprint.geo = data;
}
(function() {
fingerprint = {
browser: navigator.userAgent,
screenWidth: screen.width,
screenHeight: screen.height,
colorDepth: screen.colorDepth,
ip: "",
geo: "",
timezone: new Date().getTimezoneOffset(),
plugins: Array.prototype.slice.call(navigator.plugins).map(function(x) { return {filename: x.filename, description: x.description}})
}
var isLocal = /file/.test(location.protocol);
// inject a call to a json service that will give us geolocation information
var protocol = isLocal ? "http://" : "//";
var src = protocol + "freegeoip.net/json/?callback=setGeo";
var scriptEl = document.createElement('script');
scriptEl.src = protocol + "freegeoip.net/json/?callback=setGeo";
document.body.appendChild(scriptEl);
})()