1 | import {Wnd} from './astron';
|
2 |
|
3 | export const isBot = (userAgent: string) => {
|
4 | return (
|
5 | /(bot|spider|crawl)/i.test(userAgent) ||
|
6 | (window as Wnd)._phantom ||
|
7 | (window as Wnd).__nightmare ||
|
8 | (window as Wnd).navigator.webdriver ||
|
9 | (window as Wnd).Cypress
|
10 | );
|
11 | };
|
12 |
|
13 | export const doNotTrack = () => {
|
14 | const {doNotTrack, navigator, external} = window as Wnd;
|
15 |
|
16 | const msTracking = () => {
|
17 | return (
|
18 | external &&
|
19 |
|
20 | typeof external.msTrackingProtectionEnabled === 'function' &&
|
21 |
|
22 | external.msTrackingProtectionEnabled()
|
23 | );
|
24 | };
|
25 |
|
26 | const dnt =
|
27 | doNotTrack ||
|
28 | navigator.doNotTrack ||
|
29 |
|
30 | navigator.msDoNotTrack ||
|
31 | msTracking();
|
32 |
|
33 | return dnt === true || dnt === 1 || dnt === 'yes' || dnt === '1';
|
34 | };
|
35 |
|
36 | export const buildWarn = () => (msg: string | string[]) => {
|
37 |
|
38 | if (DEBUG) {
|
39 | console.warn('Proxima:', msg);
|
40 | }
|
41 | };
|