Last active
July 25, 2024 01:46
-
-
Save ravindUwU/1189efd43baa306f61ef612d4e92d775 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* 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