browser_object_checks.tsx
1 import { md5hex } from "../../../impl/utils"; 2 import Code from "../../Code"; 3 import Output from "../../Output"; 4 5 const BrowserObjectChecksDemo = () => { 6 return ( 7 <div> 8 <Code 9 snippet={` 10 () => { 11 const properties = [ 12 "chrome", 13 "safari", 14 "__crWeb", 15 "__gCrWeb", 16 "yandex", 17 "__yb", 18 "__ybro", 19 "__firefox__", 20 "firefox", 21 "__edgeTrackingPreventionStatistics", 22 "webkit", 23 "oprt", 24 "samsungAr", 25 "ucweb", 26 "UCShellJava", 27 "puffinDevice", 28 "opr", 29 ].reduce( 30 (acc, curr) => 31 window[curr] && typeof window[curr] === "object" 32 ? [].concat(acc, [curr]) 33 : acc, 34 [] 35 ); 36 37 return properties.length > 0 38 ? md5hex(properties.sort().join(",")) 39 : null; 40 } 41 `.trim()} 42 /> 43 44 <Output 45 generator={() => { 46 const properties = [ 47 "chrome", 48 "safari", 49 "__crWeb", 50 "__gCrWeb", 51 "yandex", 52 "__yb", 53 "__ybro", 54 "__firefox__", 55 "firefox", 56 "__edgeTrackingPreventionStatistics", 57 "webkit", 58 "oprt", 59 "samsungAr", 60 "ucweb", 61 "UCShellJava", 62 "puffinDevice", 63 "opr", 64 ].reduce( 65 (acc, curr) => 66 // @ts-expect-error 67 window[curr] && typeof window[curr] === "object" 68 ? // @ts-expect-error 69 [].concat(acc, [curr]) 70 : acc, 71 [] 72 ); 73 74 return properties.length > 0 75 ? md5hex(properties.sort().join(",")) 76 : null; 77 }} 78 /> 79 </div> 80 ); 81 }; 82 83 export default BrowserObjectChecksDemo;