aboutsummaryrefslogtreecommitdiff
path: root/webAO
diff options
context:
space:
mode:
authorstonedDiscord <Tukz@gmx.de>2022-03-07 20:36:07 +0100
committerstonedDiscord <Tukz@gmx.de>2022-03-07 20:36:07 +0100
commit1eacc38833b2ad0054f197d84f522c70119f9855 (patch)
tree208d29c2f0a1817df837a81bdeeea69240a631ed /webAO
parentd2bdf2238606450256ce53ee35c5cd369bb4f5bd (diff)
update fingerprintjs for real
Diffstat (limited to 'webAO')
-rw-r--r--webAO/client.js26
-rw-r--r--webAO/master.js31
2 files changed, 14 insertions, 43 deletions
diff --git a/webAO/client.js b/webAO/client.js
index 67a7af0..bd8710a 100644
--- a/webAO/client.js
+++ b/webAO/client.js
@@ -4,7 +4,7 @@
* credits to aleks for original idea and source
*/
-import Fingerprint2 from 'fingerprintjs2';
+import FingerprintJS from '@fingerprintjs/fingerprintjs'
import { EventEmitter } from 'events';
import {
@@ -65,29 +65,17 @@ function isLowMemory() {
}
}
-if (window.requestIdleCallback) {
- requestIdleCallback(() => {
- Fingerprint2.get(options, (components) => {
- hdid = Fingerprint2.x64hash128(components.reduce((a, b) => `${a.value || a}, ${b.value}`), 31);
+const fpPromise = FingerprintJS.load()
+fpPromise
+ .then(fp => fp.get())
+ .then(result => {
+ hdid = result.visitorId;
client = new Client(serverIP);
viewport = new Viewport();
isLowMemory();
client.loadResources();
- });
- });
-} else {
- setTimeout(() => {
- Fingerprint2.get(options, (components) => {
- hdid = Fingerprint2.x64hash128(components.reduce((a, b) => `${a.value || a}, ${b.value}`), 31);
- client = new Client(serverIP);
- viewport = new Viewport();
-
- isLowMemory();
- client.loadResources();
- });
- }, 500);
-}
+});
let lastICMessageTime = new Date(0);
diff --git a/webAO/master.js b/webAO/master.js
index b2bf0b6..4ff6402 100644
--- a/webAO/master.js
+++ b/webAO/master.js
@@ -1,4 +1,4 @@
-import Fingerprint2 from 'fingerprintjs2';
+import FingerprintJS from '@fingerprintjs/fingerprintjs'
import { unescapeChat, safe_tags } from './encoding.js';
@@ -21,10 +21,11 @@ servers[-1] = {
name: 'Localhost', description: 'This is your computer on port 50001', ip: '127.0.0.1', port: 50001, assets: '', online: 'Online: ?/?',
};
-if (window.requestIdleCallback) {
- requestIdleCallback(() => {
- Fingerprint2.get(options, (components) => {
- hdid = Fingerprint2.x64hash128(components.reduce((a, b) => `${a.value || a}, ${b.value}`), 31);
+const fpPromise = FingerprintJS.load()
+fpPromise
+ .then(fp => fp.get())
+ .then(result => {
+ hdid = result.visitorId;
check_https();
@@ -35,25 +36,7 @@ if (window.requestIdleCallback) {
// i don't need the ms to play alone
setTimeout(() => checkOnline(-1, '127.0.0.1:50001'), 0);
- });
- });
-} else {
- setTimeout(() => {
- Fingerprint2.get(options, (components) => {
- hdid = Fingerprint2.x64hash128(components.reduce((a, b) => `${a.value || a}, ${b.value}`), 31);
-
- check_https();
-
- masterserver = new WebSocket(`ws://${MASTERSERVER_IP}`);
- masterserver.onopen = (evt) => onOpen(evt);
- masterserver.onerror = (evt) => onError(evt);
- masterserver.onmessage = (evt) => onMessage(evt);
-
- // i don't need the ms to play alone
- setTimeout(() => checkOnline(-1, '127.0.0.1:50001'), 0);
- });
- }, 500);
-}
+});
export function check_https() {
if (document.location.protocol === 'https:') {