diff --git a/client/main.tsx b/client/main.tsx index 7eb69630..16964ed3 100644 --- a/client/main.tsx +++ b/client/main.tsx @@ -16,3 +16,40 @@ root.render( , ); + +// Safely load HelloSkip agent: fetch the script first and only evaluate if fetching succeeds. +// This prevents the external script from executing its runtime network checks when the host +// environment blocks cross-origin requests, avoiding uncaught "Failed to fetch" errors. +(async function loadHelloSkipAgent() { + try { + if (!('fetch' in window) || !navigator.onLine) return; + + const controller = new AbortController(); + const timeout = setTimeout(() => controller.abort(), 5000); + + const res = await fetch('https://helloskip.com/agent.js', { signal: controller.signal }); + clearTimeout(timeout); + + if (!res.ok) throw new Error('Failed to download HelloSkip agent script'); + + const scriptText = await res.text(); + const blob = new Blob([scriptText], { type: 'application/javascript' }); + const url = URL.createObjectURL(blob); + + const s = document.createElement('script'); + s.src = url; + s.dataset.agentId = 'vVEuropu5l7xvT4Swwif'; + s.async = true; + s.onload = () => { + URL.revokeObjectURL(url); + }; + s.onerror = (e) => { + console.warn('HelloSkip agent failed to execute', e); + URL.revokeObjectURL(url); + }; + + document.body.appendChild(s); + } catch (err) { + console.warn('Skipped loading HelloSkip agent:', err); + } +})(); diff --git a/index.html b/index.html index 9d712125..b52c50c3 100644 --- a/index.html +++ b/index.html @@ -173,6 +173,5 @@
-