blob: 6d27cf19e56f931374277fb4521364b24ea34676 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
<!DOCTYPE html>
<meta charset="utf-8">
<script>
const params =new URLSearchParams(location.search);
const mode = params.get("mode") || "cors";
const path = params.get('path');
const bufferPromise =
new Promise(resolve =>
fetch(path, {mode})
.then(response => resolve(response.arrayBuffer()))
.catch(() => resolve(new Uint8Array())));
const entryPromise = new Promise(resolve => {
new PerformanceObserver(entries => {
const byName = entries.getEntriesByType("resource").find(e => e.name.includes(path));
if (byName)
resolve(byName);
}).observe({entryTypes: ["resource"]});
});
Promise.all([bufferPromise, entryPromise]).then(([buffer, entry]) => {
parent.postMessage({
buffer,
entry: entry.toJSON(),
}, '*');
});
</script>
|