ShrinkWatch EU is an open source extension that shows the price per kg or litre on 71 European supermarket web shops. Asking for all of them at install time would mean more than 180 site patterns in the permission warning, and a harder store review. So only six shops are enabled at install. Every other shop is switched on by the user, one at a time, from the popup.
This post is how that works in Manifest V3, and the three bugs I hit on the way.
The manifest
The six default shops go in host_permissions and a static content_scripts entry. Everything else goes in optional_host_permissions :
{ "permissions" : [ "storage" , "scripting" , "activeTab" ], "host_permissions" : [ "https://*.konzum.hr/*" ], "optional_host_permissions" : [ "https://*.rewe.de/*" , "https://*.lidl.fr/*" ] }
Enter fullscreen mode
Exit fullscreen mode
activeTab covers a "Check this page now" button that works on any site, once, without a standing permission.
Asking for the permission
The request must run directly in the click…