Skip to content

Instantly share code, notes, and snippets.

@ravindUwU
Last active July 25, 2024 01:46
Show Gist options
  • Save ravindUwU/1189efd43baa306f61ef612d4e92d775 to your computer and use it in GitHub Desktop.
Save ravindUwU/1189efd43baa306f61ef612d4e92d775 to your computer and use it in GitHub Desktop.
/**
* Finds the <link>ed PWA manifest (https://developer.mozilla.org/docs/Web/Manifest) and changes its
* properties. Then, updates the <link> to a data URL with the contents of the changed manifest.
*
* It's possible that this might prevent manifest updates (https://web.dev/articles/manifest-updates)
* but I'm unsure; haven't investigated this.
*/
(async () => {
// Get manifest JSON.
const link = document.querySelector('link[rel="manifest"]');
const manifest = await (await fetch(link.href)).json();
// Change properties of the manifest here.
manifest.start_url = '/owo';
delete manifest.scope;
// Update <link>.
link.href = `data:application/manifest+json;base64,${btoa(JSON.stringify(manifest))}`;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment