-
Notifications
You must be signed in to change notification settings - Fork 29
/
fingerprintjs3.js
61 lines (55 loc) · 1.33 KB
/
fingerprintjs3.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* eslint-disable func-names */
import {
hit,
noopStr,
} from '../helpers/index';
/**
* @redirect fingerprintjs3
*
* @description
* Mocks FingerprintJS v3
* https://github.com/fingerprintjs
*
* Related UBO redirect resource:
* https://github.com/gorhill/uBlock/blob/master/src/web_accessible_resources/fingerprint3.js
*
* ### Examples
*
* ```adblock
* ||example.com/js/ufe/isomorphic/thirdparty/fp.min.js$script,redirect=fingerprintjs3
* ```
*
* @added v1.6.2.
*/
export function Fingerprintjs3(source) {
const visitorId = (() => {
let id = '';
for (let i = 0; i < 8; i += 1) {
id += (Math.random() * 0x10000 + 0x1000).toString(16).slice(-4);
}
return id;
})();
const FingerprintJS = function () { };
FingerprintJS.prototype = {
load() {
return Promise.resolve(new FingerprintJS());
},
get() {
return Promise.resolve({
visitorId,
});
},
hashComponents: noopStr,
};
window.FingerprintJS = new FingerprintJS();
hit(source);
}
Fingerprintjs3.names = [
'fingerprintjs3',
// redirect aliases are needed for conversion:
// prefixed for us
'ubo-fingerprint3.js',
// original ubo name
'fingerprint3.js',
];
Fingerprintjs3.injections = [hit, noopStr];