Open rhelmer opened 2 years ago
It looks like this might be supported in Chrome now, Manifest v3 only:
Firefox supports it in MV3 as of 101, and MV2 as of 102+, so I think we might be able to switch to this now.
OK this seems to work testing latest Chrome + MV3, we will need to make a few adjustments:
permissions.js
needs to use host_permissions
manifest key for MV3, and continue using permissions
for Firefox+MV2scripting
permissioncontentScript.js
module and simply use browser.scripting
API which is cross-browser now
Firefox supports dynamically loading content scripts, but until Chrome ships an equivalent API we don't have a way to restrict content scripts to only run on certain domains (specified as match patterns).
In PR https://github.com/mozilla-rally/web-science/issues/281 we attempted to write a roll-up plugin to generate entries , but Chrome cannot handle the ~4k sample of domains from the Beyond the Paywall study that I tested.
A few approaches come to mind:
Since WebScience is built by the caller, I think both of these are pretty easy to do. The trade-offs are that (1) involves more messaging and runtime overhead, and (2) will cause content scripts to be larger on average, but no messaging would be required and the content scripts could run totally standalone.
(1) is probably the most flexible, and it might end up mattering if there are several content scripts that filter on a very large set of match patterns.