1 2(function () { 3 const GTM_ID = "GTM-KP5XRG5D"; 4 5 /* ================================ 6 BOT GUARD (Analytics Clean) 7 ================================= */ 8 const isBot = /bot|crawler|spider|crawling/i.test(navigator.userAgent); 9 if (isBot) return; 10 11 /* ================================ 12 HELPERS 13 ================================= */ 14 function onIdle(cb, timeout = 3000) { 15 if ("requestIdleCallback" in window) { 16 requestIdleCallback(cb, { timeout }); 17 } else { 18 setTimeout(cb, Math.min(timeout, 2000)); 19 } 20 } 21 22 function afterDelay(ms, cb) { 23 setTimeout(cb, ms); 24 } 25 26 function onceUserIntent(cb) { 27 let done = false; 28 29 const run = () => { 30 if (done) return; 31 done = true; 32 cleanup(); 33 cb(); 34 }; 35 36 const cleanup = () => { 37 window.removeEventListener("scroll", run, true); 38 window.removeEventListener("pointerdown", run, true); 39 window.removeEventListener("keydown", run, true); 40 window.removeEventListener("touchstart", run, true); 41 }; 42 43 ["scroll", "pointerdown", "keydown", "touchstart"].forEach((evt) => 44 window.addEventListener(evt, run, { capture: true, passive: true }) 45 ); 46 47 afterDelay(12000, run); 48 } 49 50 function loadScriptOnce(id, src, onloadCb) { 51 if (document.getElementById(id)) return; 52 53 const s = document.createElement("script"); 54 s.id = id; 55 s.async = true; 56 s.src = src; 57 58 s.onload = () => { 59 if (typeof onloadCb === "function") onloadCb(); 60 }; 61 62 document.head.appendChild(s); 63 } 64 65 /* ================================ 66 CONFIG (GTM + FALLBACK DIRECT) 67 ================================= */ 68 const USE_GTM = true; 69 const LOAD_VENDORS_DIRECTLY = true; 70 71 /* ================================ 72 LOADERS 73 ================================= */ 74 75 function loadGTM() { 76 if (window.google_tag_manager || window._gtm_loaded) return; 77 78 window._gtm_loaded = true; 79 window.dataLayer = window.dataLayer || []; 80 window.dataLayer.push({ "gtm.start": Date.now(), event: "gtm.js" }); 81 82 loadScriptOnce( 83 "bb-gtm", 84 "https://www.googletagmanager.com/gtm.js?id=" + GTM_ID 85 ); 86 } 87 88 function loadClarity() { 89 if (window.clarity || window._clarity_loaded) return; 90 window._clarity_loaded = true; 91 92 (function (c, l, a, r, i, t, y) { 93 c[a] = 94 c[a] || 95 function () { 96 (c[a].q = c[a].q || []).push(arguments); 97 }; 98 t = l.createElement(r); 99 t.async = 1; 100 t.src = "https://www.clarity.ms/tag/" + i; 101 y = l.getElementsByTagName(r)[0]; 102 y.parentNode.insertBefore(t, y); 103 })(window, document, "clarity", "script", "umfi093rcx"); 104 } 105 106 function loadHotjar() { 107 if (window.hj || window._hj_loaded) return; 108 109 window._hj_loaded = true; 110 window._hjSettings = { hjid: 6498478, hjsv: 6 }; 111 112 window.hj = 113 window.hj || 114 function () { 115 (window.hj.q = window.hj.q || []).push(arguments); 116 }; 117 118 loadScriptOnce( 119 "bb-hotjar", 120 "https://static.hotjar.com/c/hotjar-6498478.js?sv=6" 121 ); 122 } 123 124 /* ================================ 125 STRATEGY (FINAL) 126 ================================= */ 127 128 // 1) Always try GTM first 129 if (USE_GTM) { 130 onIdle(loadGTM, 500); 131 } 132 133 // 2) Fallback vendors if GTM does not load them 134 if (LOAD_VENDORS_DIRECTLY) { 135 afterDelay(3500, () => { 136 if (typeof window.clarity === "undefined") { 137 onIdle(loadClarity, 4000); 138 } 139 }); 140 141 onceUserIntent(() => { 142 afterDelay(1500, () => { 143 if (typeof window.hj === "undefined") { 144 onIdle(loadHotjar, 5000); 145 } 146 }); 147 }); 148 } 149})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.