clientjs icon indicating copy to clipboard operation
clientjs copied to clipboard

The examples provided in the documentation may generate errors

Open webpwnized opened this issue 2 years ago • 0 comments

The examples provided in the documentation may generate errors. Here is a working example of how to use in a browser such as Firefox. This example ensures the script does not run until after the Body has loaded since the font detector script relies on the Body element.

``

        document.addEventListener('readystatechange', event => {
            // When window loaded ( external resources are loaded too- `css`,`src`, etc...) 
            if (event.target.readyState === "complete") {
                // in a browser, when using a script tag:
                const ClientJS = window.ClientJS;

                // Create a new ClientJS object
                const client = new ClientJS();

                // Get the client's fingerprint id
                const fingerprint = client.getFingerprint();

                // Print the 32bit hash id to the console
                console.log(fingerprint);
            }
        });

    </script>

``

webpwnized avatar Jan 15 '24 22:01 webpwnized