UNPKG

933 BPlain TextView Raw
1import {Wnd} from './astron';
2
3export 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
13export const doNotTrack = () => {
14 const {doNotTrack, navigator, external} = window as Wnd;
15
16 const msTracking = () => {
17 return (
18 external &&
19 // @ts-ignore
20 typeof external.msTrackingProtectionEnabled === 'function' &&
21 // @ts-ignore
22 external.msTrackingProtectionEnabled()
23 );
24 };
25
26 const dnt =
27 doNotTrack ||
28 navigator.doNotTrack ||
29 // @ts-ignore
30 navigator.msDoNotTrack ||
31 msTracking();
32
33 return dnt === true || dnt === 1 || dnt === 'yes' || dnt === '1';
34};
35
36export const buildWarn = () => (msg: string | string[]) => {
37 // @ts-ignore
38 if (DEBUG) {
39 console.warn('Proxima:', msg);
40 }
41};