Created
September 1, 2020 16:33
-
-
Save kgiszewski/c64bc7b9f8282c701829dae8acb9b244 to your computer and use it in GitHub Desktop.
FP.js
This file contains 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
<html> | |
<body> | |
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/fingerprintjs2/2.1.0/fingerprint2.js" integrity="sha512-8sIrWJ3xijgfDZyiv3SLPeUrcwD8k0B6zr3wZ5oSyTrv+X7TOlcCeat9IbyZp3IsK1evjCov4IklJ3RULQmohA==" crossorigin="anonymous"></script> | |
<script> | |
$(function(){ | |
if (window.requestIdleCallback) { | |
requestIdleCallback(function () { | |
Fingerprint2.get(function (components) { | |
console.log(getHash(components)); | |
}) | |
}) | |
} else { | |
setTimeout(function () { | |
Fingerprint2.get(function (components) { | |
console.log(getHash(components)); | |
}) | |
}, 500) | |
} | |
}); | |
function getHash(components) | |
{ | |
const values = components.map(component => component.value) | |
console.log('fingerprint hash components', components) | |
return String(Fingerprint2.x64hash128(values.join(''), 31)) | |
} | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment