项目地址:https://github.com/fingerprintjs/fingerprintjs
<script>
// Initialize the agent at application startup.
const fpPromise = new Promise((resolve, reject) => {
const script = document.createElement('script')
script.onload = resolve
script.onerror = reject
script.async = true
script.src = 'https://cdn.jsdelivr.net/npm/'
+ '@fingerprintjs/fingerprintjs@3/dist/fp.min.js'
document.head.appendChild(script)
})
.then(() => FingerprintJS.load())
// Get the visitor identifier when you need it.
fpPromise
.then(fp => fp.get())
.then(result => {
// This is the visitor identifier:
const visitorId = result.visitorId
console.log(visitorId)
})
</script>