Fetch hook overhead

Every network request on the page was being processed by the overlay hook, even non-wplace requests
This commit is contained in:
Decrypt 2025-08-22 16:23:12 +02:00
parent 30e98ecffc
commit 5b12b51cf4

View file

@ -32,6 +32,16 @@ export function attachHook() {
const hookedFetch = async (input: RequestInfo | URL, init?: RequestInit) => {
const urlStr = typeof input === 'string' ? input : ((input as Request).url) || '';
// EARLY FILTERING: Quick hostname check to skip non-wplace requests
if (!urlStr.includes('backend.wplace.live')) {
return originalFetch(input as any, init as any);
}
// EARLY FILTERING: Quick path check to skip non-tile/non-pixel requests
if (!urlStr.includes('/files/') && !urlStr.includes('/s0/pixel/')) {
return originalFetch(input as any, init as any);
}
// Anchor auto-capture: watch pixel endpoint, then store/normalize
if (config.autoCapturePixelUrl && config.activeOverlayId) {
const pixelMatch = matchPixelUrl(urlStr);