Created
May 12, 2021 03:59
-
-
Save rviscomi/70d588cf8643dce4fb55050388fca836 to your computer and use it in GitHub Desktop.
WebPageTest custom metric: web app manifest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[web-app-manifest] | |
const response_bodies = $WPT_BODIES; | |
const manifestURLs = new Set(Array.from(document.querySelectorAll('link[rel=manifest]')).map(link => { | |
const base = new URL(location.href).origin; | |
const href = link.getAttribute('href'); | |
return new URL(href, base).href; | |
})); | |
const manifests = response_bodies.filter(har => { | |
return manifestURLs.has(har.url); | |
}).map(har => { | |
let manifest; | |
try { | |
manifest = JSON.parse(har.response_body); | |
} catch (e) { | |
manifest = har.response_body; | |
} | |
return [har.url, manifest]; | |
}); | |
return JSON.stringify(Object.fromEntries(manifests), null, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment