prefetch-with-csp.html (707B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <script> 5 let link = document.createElement("link"); 6 link.rel = "prefetch"; 7 const bc = new BroadcastChannel(new URLSearchParams(location.search).get("uid")); 8 link.addEventListener("error", e => bc.postMessage(false)); 9 link.href = "pass.png"; 10 document.head.appendChild(link); 11 const observer = new PerformanceObserver(entries => { 12 const found = entries.getEntriesByName(new URL("pass.png", location.href).href); 13 if (found.length) 14 bc.postMessage(found[0].encodedBodySize > 0); 15 }); 16 observer.observe({entryTypes: ["resource"]}); 17 </script> 18 </head> 19 </html>