Skip to content

Instantly share code, notes, and snippets.

@huynhducduy
Created July 8, 2025 05:52
Show Gist options
  • Save huynhducduy/01713a460ed51cc2c39defc64bc5b9d6 to your computer and use it in GitHub Desktop.
Save huynhducduy/01713a460ed51cc2c39defc64bc5b9d6 to your computer and use it in GitHub Desktop.
function r(e) {
var t, n;
t = Array.prototype.forEach,
n = Array.prototype.map,
this.each = function(e, n, r) {
if (null !== e)
if (t && e.forEach === t)
e.forEach(n, r);
else if (e.length === +e.length) {
for (var a = 0, i = e.length; a < i; a++)
if (n.call(r, e[a], a, e) === {})
return
} else
for (var o in e)
if (e.hasOwnProperty(o) && n.call(r, e[o], o, e) === {})
return
}
,
this.map = function(e, t, r) {
var a = [];
return null == e ? a : n && e.map === n ? e.map(t, r) : (this.each(e, function(e, n, i) {
a[a.length] = t.call(r, e, n, i)
}),
a)
}
,
"object" == typeof e ? (this.hasher = e.hasher,
this.screen_resolution = e.screen_resolution,
this.canvas = e.canvas,
this.ie_activex = e.ie_activex) : "function" == typeof e && (this.hasher = e),
this.get = function() {
var e = [];
(e.push(navigator.userAgent),
e.push(navigator.language),
e.push(screen.colorDepth),
this.screen_resolution) && (void 0 !== this.getScreenResolution() && e.push(this.getScreenResolution().join("x")));
return e.push((new Date).getTimezoneOffset()),
e.push(this.hasSessionStorage()),
e.push(this.hasLocalStorage()),
e.push(!!window.indexedDB),
document.body ? e.push(typeof document.body.addBehavior) : e.push("undefined"),
e.push(typeof window.openDatabase),
e.push(navigator.cpuClass),
e.push(navigator.platform),
e.push(navigator.doNotTrack),
e.push(this.getPluginsString()),
this.canvas && this.isCanvasSupported() && e.push(this.getCanvasFingerprint()),
this.hasher ? this.hasher(e.join("###"), 31) : this.murmurhash3_32_gc(e.join("###"), 31)
}
,
this.murmurhash3_32_gc = function(e, t) {
var n, r, a, i, o, s, c, u;
for (n = 3 & e.length,
r = e.length - n,
a = t,
o = 3432918353,
s = 461845907,
u = 0; u < r; )
c = 255 & e.charCodeAt(u) | (255 & e.charCodeAt(++u)) << 8 | (255 & e.charCodeAt(++u)) << 16 | (255 & e.charCodeAt(++u)) << 24,
++u,
a = 27492 + (65535 & (i = 5 * (65535 & (a = (a ^= c = (65535 & (c = (c = (65535 & c) * o + (((c >>> 16) * o & 65535) << 16) & 4294967295) << 15 | c >>> 17)) * s + (((c >>> 16) * s & 65535) << 16) & 4294967295) << 13 | a >>> 19)) + ((5 * (a >>> 16) & 65535) << 16) & 4294967295)) + ((58964 + (i >>> 16) & 65535) << 16);
switch (c = 0,
n) {
case 3:
c ^= (255 & e.charCodeAt(u + 2)) << 16;
case 2:
c ^= (255 & e.charCodeAt(u + 1)) << 8;
case 1:
a ^= c = (65535 & (c = (c = (65535 & (c ^= 255 & e.charCodeAt(u))) * o + (((c >>> 16) * o & 65535) << 16) & 4294967295) << 15 | c >>> 17)) * s + (((c >>> 16) * s & 65535) << 16) & 4294967295
}
return a ^= e.length,
a = 2246822507 * (65535 & (a ^= a >>> 16)) + ((2246822507 * (a >>> 16) & 65535) << 16) & 4294967295,
a = 3266489909 * (65535 & (a ^= a >>> 13)) + ((3266489909 * (a >>> 16) & 65535) << 16) & 4294967295,
(a ^= a >>> 16) >>> 0
}
,
this.hasLocalStorage = function() {
try {
return !!window.localStorage
} catch (e) {
return !0
}
}
,
this.hasSessionStorage = function() {
try {
return !!window.sessionStorage
} catch (e) {
return !0
}
}
,
this.isCanvasSupported = function() {
var e = document.createElement("canvas");
return !(!e.getContext || !e.getContext("2d"))
}
,
this.isIE = function() {
return "Microsoft Internet Explorer" === navigator.appName || !("Netscape" !== navigator.appName || !/Trident/.test(navigator.userAgent))
}
,
this.getPluginsString = function() {
return this.isIE() && this.ie_activex ? this.getIEPluginsString() : this.getRegularPluginsString()
}
,
this.getRegularPluginsString = function() {
return this.map(navigator.plugins, function(e) {
var t = this.map(e, function(e) {
return [e.type, e.suffixes].join("~")
}).join(",");
return [e.name, e.description, t].join("::")
}, this).join(";")
}
,
this.getIEPluginsString = function() {
if (window.ActiveXObject) {
var e = ["ShockwaveFlash.ShockwaveFlash", "AcroPDF.PDF", "PDF.PdfCtrl", "QuickTime.QuickTime", "rmocx.RealPlayer G2 Control", "rmocx.RealPlayer G2 Control.1", "RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)", "RealVideo.RealVideo(tm) ActiveX Control (32-bit)", "RealPlayer", "SWCtl.SWCtl", "WMPlayer.OCX", "AgControl.AgControl", "Skype.Detection"];
return this.map(e, function(e) {
try {
return new ActiveXObject(e),
e
} catch (e) {
return null
}
}).join(";")
}
return ""
}
,
this.getScreenResolution = function() {
return [screen.height, screen.width]
}
,
this.getCanvasFingerprint = function() {
var e = document.createElement("canvas")
, t = e.getContext("2d")
, n = "http://valve.github.io";
return t.textBaseline = "top",
t.font = "14px 'Arial'",
t.textBaseline = "alphabetic",
t.fillStyle = "#f60",
t.fillRect(125, 1, 62, 20),
t.fillStyle = "#069",
t.fillText(n, 2, 15),
t.fillStyle = "rgba(102, 204, 0, 0.7)",
t.fillText(n, 4, 17),
e.toDataURL()
}
}
function getDeviceFingerPrintId() {
var e = new r({
canvas: !0,
screen_resolution: !0
}).get();
return e = Math.max(e, 0),
e = Math.min(e, 4294967295),
e += -2147483648
}
getDeviceFingerPrintId()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment