master
kek7198 2021-12-04 17:31:44 -06:00
parent 1d0f2cd1f8
commit 819f6dea26
1 changed files with 26 additions and 1 deletions

View File

@ -78,6 +78,31 @@
<script src="/assets/js/submission_listing.js?v=3"></script> <script src="/assets/js/submission_listing.js?v=3"></script>
<script src="/assets/js/fingerprint.js?v=1"></script> {% if not v.fp %}
<script>
function fp(fp) {
var xhr = new XMLHttpRequest();
xhr.open("POST", '{{request.host_url}}fp/'+fp, true);
var form = new FormData()
form.append("formkey", formkey());
xhr.withCredentials=true;
xhr.send(form);
};
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-pro@3/dist/fp.min.js';
document.head.appendChild(script);
})
.then(() => FingerprintJS.load({token: '{{environ.get("FP")}}'}));
fpPromise
.then(fp => fp.get())
.then(result => {if (result.visitorId != '{{v.fp}}') fp(result.visitorId);})
</script>
{% endif %}
{% endblock %} {% endblock %}