web-monetization-extension
web-monetization-extension copied to clipboard
Move to MV3 as MV2 is going to be deprecated
CORS on MV3 Use MonetizationEvent class rather than using custom events Add script injection into content script on MV3 with monetization event (if necessary add script CSP sha)
- The component that searches for WM tags and event routing to WM tags should not run in the main JS context
Prioritising compatibility for Chrome first. Agreed to work on compatibility for other engines after work-week.
Diana will investigate the approach that we'll need to ensure that the extension's polyfill capability is secure once we are MV3 compatible
There seems to be an issue with Firefox browser compatibility that will be an impediment for the MV3 update for the Firefox build.
https://bugzilla.mozilla.org/show_bug.cgi?id=1851083
Also relevant bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1573659 Firefox MV3 doesn't support service worker as of now. We might need separate implementation wrappers as background script/service worker.
Edit: Actually won't need two implementations, as we'll use the SW as if it's a script (i.e. we'll likely not be using any special SW behavior). So, would just need to update manifest.background for Firefox vs others.
Another difference we need to handle: By default, MV3 disables our all hosts permissions. That's something we need to request user, otherwise much of the extension won't work - can only open the popup, no payments or anything. Unfortunately, can't ask that permission on install either - needs user interaction. So, I'll see if we do something in UI (popup), or do it before we even show allow opening popup (less UI work that way).
Another difference we need to handle: By default, MV3 disables our all hosts permissions. That's something we need to request user, otherwise much of the extension won't work - can only open the popup, no payments or anything. Unfortunately, can't ask that permission on install either - needs user interaction. So, I'll see if we do something in UI (popup), or do it before we even show allow opening popup (less UI work that way).
Interesting, thanks Sid. I'd love to see a demo of the alternatives, actually.
Also, not a blocker, but Firefox doesn't support content script execution world yet as mentioned in https://github.com/interledger/web-monetization-extension/issues/9.
https://bugzilla.mozilla.org/show_bug.cgi?id=1736575
So, we'll have to stick with the inject script.innerHTML hack for now.
Just faced https://github.com/interledger/web-monetization-extension/issues/23#issuecomment-2147681542 in Chrome. Not in Firefox.
Ok, found the best bug yet. Thanks to webpack (or our configuration). It adds a document to background.js, but Chrome MV3 (with Service Worker) doesn't support document, so I kept getting document is not defined errors from somewhere on trying to connect wallet.
/******/ /* webpack/runtime/load script */
/******/ (() => {
/******/ var inProgress = {};
/******/ var dataWebpackPrefix = "web-monetization-extension:";
/******/ // loadScript function to load a script via script tag
/******/ __webpack_require__.l = (url, done, key, chunkId) => {
/******/ if(inProgress[url]) { inProgress[url].push(done); return; }
/******/ var script, needAttach;
/******/ if(key !== undefined) {
/******/ var scripts = document.getElementsByTagName("script");
Stack trace pointed only to our logger, so had to grep for document in bundles. Will check how do we avoid webpack adding that.
Rest of the extension seems to be working fine with Firefox/Chrome MV3 🎉
Update: Solved with:
new optimize.LimitChunkCountPlugin({
maxChunks: 1
}),
🎉 Will be sending PR on Monday, after some cleanups and looking into all-hosts permission approach as a follow-up.
Question: @tselit @ioana-chiorean @raducristianpopa @dianafulga Should we remove manifest v2 support, or continue to support it? I found extension worked fine with Firefox MV3.
Question: @tselit @ioana-chiorean @raducristianpopa @dianafulga Should we remove manifest v2 support, or continue to support it? I found extension worked fine with Firefox MV3.
Thanks @sidvishnoi...it's interesting to hear that the extension using MV3 worked fine on Firefox (which version)?
I think you might've referenced this earlier, so I'm keen to understand how you got around this: "Chrome’s version of MV3 requires service worker-based background scripts, which Firefox does not support yet."
Please check linked PR about Firefox/Chrome Script/SW, I added a review comment there about this. Basically we aren't using anything particular about service worker, so a script is exactly same as SW. And the keep alive works for us as we keep messaging between content script often.
I actually tested on latest Firefox, but I think last 3 versions should work fine too.
Working fine on Firefox 110 (released 2023-02-14), including tipping and continuous payments.
(Firefox started MV3 support with 109, but I tested on 110)
Ready to merge. Further discussion/consideration about the UI design/composition to address the issue with the scroll bar. The other consideration (also a separate ticket) would be possibly overhauling the entire UI of the extension, possibly giving the user more direction on what to do next.