Created
March 25, 2020 02:12
-
-
Save binary4cat/ce928c0f29e083f049cfa2dbc9757eef to your computer and use it in GitHub Desktop.
fingerprint2 demo
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
<script src="https://cdn.staticfile.org/fingerprintjs2/2.1.0/fingerprint2.min.js"></script> | |
<script> | |
function start() { | |
const start = new Date().getTime(); | |
let view = document.querySelector('#view'); | |
view.innerHTML = ''; | |
let excludes = {}; | |
if (!document.querySelector('#userAgent').checked) { | |
excludes.userAgent = true; | |
} | |
if (!document.querySelector('#audio').checked) { | |
excludes.audio = true; | |
} | |
if (!document.querySelector('#enumerateDevices').checked) { | |
excludes.enumerateDevices = true; | |
} | |
if (!document.querySelector('#fonts').checked) { | |
excludes.fonts = true; | |
} | |
if (!document.querySelector('#fontsFlash').checked) { | |
excludes.fontsFlash = true; | |
} | |
if (!document.querySelector('#webgl').checked) { | |
excludes.webgl = true; | |
} | |
if (!document.querySelector('#canvas').checked) { | |
excludes.canvas = true; | |
} | |
let options = {excludes: excludes} | |
Fingerprint2.get(options, function (components) { | |
// 参数 | |
const values = components.map(function (component) { | |
return component.value | |
}); | |
// 指纹 | |
const murmur = Fingerprint2.x64hash128(values.join(''), 31); | |
view.innerHTML += '<p>指纹 : ' + murmur + '</p>'; | |
view.innerHTML += '<p>消耗 : ' + (new Date().getTime() - start) + ' 毫秒</p>'; | |
view.innerHTML += '<p>使用的参数 : </p>'; | |
for (const c of components) { | |
view.innerHTML += '<p>' + c.key + ' : ' + c.value + '</p>'; | |
} | |
}); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment