(() => { if (globalThis.__earthLocalReplayRewriteInstalled) return; globalThis.__earthLocalReplayRewriteInstalled = true; const localOrigin = "https://www.zeromaps.com.cn"; const hosts = new Set([ "earth.google.com", "earth-pa.clients6.google.com", "feedback-pa.clients6.google.com", "kh.google.com", "www.gstatic.com", "csi.gstatic.com", "fonts.gstatic.com", "lh5.googleusercontent.com", "streetviewpixels-pa.googleapis.com", "www.google.com", "www.google-analytics.com", "play.google.com", "apis.google.com", "accounts.google.com", "firebase.googleapis.com", "firebaseinstallations.googleapis.com", "htapi.google.com", "www.googletagmanager.com", "mw1.gstatic.com", "firebaseremoteconfig.googleapis.com" ]); function localize(input) { try { const raw = typeof input === "string" ? input : input && input.url; const u = new URL(raw, globalThis.location && globalThis.location.href); if ((u.protocol === "https:" || u.protocol === "http:") && hosts.has(u.hostname)) { return localOrigin + "/__origin/" + u.hostname + u.pathname + u.search + u.hash; } } catch (_) {} return input; } if (typeof globalThis.fetch === "function") { const originalFetch = globalThis.fetch; globalThis.fetch = function(input, init) { if (typeof Request !== "undefined" && input instanceof Request) { const rewritten = localize(input.url); if (rewritten !== input.url) input = new Request(rewritten, input); } else { input = localize(input); } return originalFetch.call(this, input, init); }; } if (globalThis.XMLHttpRequest && globalThis.XMLHttpRequest.prototype) { const originalOpen = globalThis.XMLHttpRequest.prototype.open; globalThis.XMLHttpRequest.prototype.open = function(method, url, ...rest) { return originalOpen.call(this, method, localize(url), ...rest); }; } if (globalThis.Element && globalThis.Element.prototype) { const originalSetAttribute = globalThis.Element.prototype.setAttribute; globalThis.Element.prototype.setAttribute = function(name, value, ...rest) { const lower = String(name).toLowerCase(); if (lower === "src" || lower === "href" || lower === "action") value = localize(value); return originalSetAttribute.call(this, name, value, ...rest); }; } // Prevent crossorigin credentials mismatch on preloaded scripts. // The HTML preload omits crossorigin, but JS engines (e.g. Flutter) set // crossOrigin="anonymous" on