Nat TaylorBlog, Product Management & Tinkering

Chrome New Window Shortcut for Specific Doc

Published on . Updated on

I use a Google doc for To Do & Notes and rely on Option + Tab for window switching on my Mac, which is incompatible with Chrome tabs. Flotato mostly resolved this by making tabs into windows, but it was a memory hog, had it’s own cookie store and I much prefer Chrome’s native PWA shortcuts. However docs.google.com‘s manifest.json sets start_url to the Docs homepage, so native shorcuts don’t quite work. Well… we can fix that :)

Create a Chrome PWA Shortcut with manifest override

  1. Open the page you want to open as a PWA shortcut
  2. Open devtools and run the script below.
  3. Create shortcut (3-dot > Save & Share > Create Shortcut)

That’s it. Now you have a shortcut!

manifest = document.head.querySelector('link[rel="manifest"]');
json = await fetch(href = manifest.href).then(res => res.json());
base = href.substring(0, href.lastIndexOf('/') + 1);

json.start_url = window.location.href + '?usp=installed_webapp';
json.icons.forEach((icon) => icon.src = base + icon.src);

manifest.href = 'data:application/manifest+json,' + encodeURIComponent(JSON.stringify(json));

json;

Popular Posts

Post Navigation

«
»