From 54a363e4f0e948d2600f0bb760fb2e1dca995576 Mon Sep 17 00:00:00 2001 From: z0ccc Date: Tue, 28 Sep 2021 21:41:55 -0400 Subject: [PATCH] Fixed fingerprint functionality --- frontend/src/components/FingerprintBlock.js | 38 ++++++++++----------- frontend/src/styles/App.css | 2 +- frontend/src/utils/fingerprint.js | 6 ++-- 3 files changed, 21 insertions(+), 25 deletions(-) diff --git a/frontend/src/components/FingerprintBlock.js b/frontend/src/components/FingerprintBlock.js index ffc7d06..4c8e995 100644 --- a/frontend/src/components/FingerprintBlock.js +++ b/frontend/src/components/FingerprintBlock.js @@ -1,4 +1,3 @@ -/* eslint-disable no-unused-vars */ import { useState, useEffect } from 'react'; import Block from './Block'; import Table from './Table'; @@ -11,37 +10,36 @@ import { const FingerprintBlock = ({ workerData }) => { const [signature, setSignature] = useState(); + const [load, setload] = useState(false); + const hash = getHash(workerData); useEffect(() => { - if (signature) { - postSignature(hash, signature); - } else { - getSignature(hash, setSignature); - } - }, [signature]); + getSignature(hash, setSignature, setload); + }, []); - const hash = getHash(workerData); return (

Fingerprint

- <> - {signature ? ( -
- - - ) : ( -
-
{hash}
-
- )} - + {load && ( + <> + {signature !== undefined ? ( +
+
+ + ) : ( +
+
{hash}
+
+ )} + + )}

Explanation: This is a unique identifier that can be used to follow you around the web. Even if you clear cookies, change your IP or use private mode the hash will stay the same. Enter your name below and reload the page in private mode to test it out.

- setSignature(e.target[0].value)}> + postSignature(hash, e.target[0].value)}> { - console.log('1'); +const getSignature = (hash, setSignature, setload) => { axios .get(`https://api.vytal.io/fingerprint/?hash=${hash}`) .then((response) => { - console.log(response.data[response.data.length - 1]); - if (response.data.length !== 0) { setSignature(response.data[response.data.length - 1].name); } + setload(true); }); };