export const retryImageWithoutCors = (image: HTMLImageElement) => { const originalSrc = image.src; let attempted = false; const handleError = () => { if (attempted || !image.hasAttribute("crossorigin") || !originalSrc) { return; } attempted = true; image.removeAttribute("crossorigin"); image.src = originalSrc; }; image.addEventListener("error", handleError); if (image.complete && !image.naturalWidth) handleError(); return () => image.removeEventListener("error", handleError); };