What does HackerNews think of webextension-polyfill?
A lightweight polyfill library for Promise-based WebExtension APIs in Chrome
Their type definition for HAR request isn't exported https://github.com/DefinitelyTyped/DefinitelyTyped/blob/mast...
So I can't drop in replace the type on https://github.com/AndrewWalsh/openapi-devtools/blob/main/sr...
Mozilla has also done some great work building a web extension polyfill library that attempts to abstract away the differences between the browsers [2] but the translation will always be imperfect, and edge cases are abundant.
I managed to have it done with only a few places where I branch on navigator.vendor, but If I wanted to ship different versions to AMO and CWS, I'd make use of something like DefinePlugin[1] for webpack to include/exclude code based on build target.
[0] https://github.com/mozilla/webextension-polyfill/
[1] https://github.com/webpack/docs/wiki/list-of-plugins#definep...
Frankly - I'm a little peeved that Optional permissions in Firefox are STILL broken - The prompt can only be triggered in response to a user action, and Firefox blows the fuck up if you put a promise anywhere in between the user click and the call to the api. Which is hugely ironic, since Mozilla is the one pushing to move all the webext APIs to be promise based (and provides a nice helpful library for Chrome/Edge/Safari support: https://github.com/mozilla/webextension-polyfill) which... doesn't work on their platform. Doubly ironic, since the result is that most FF extensions just ask for more permissions up front, which is exactly the opposite of what you'd want in the "secure/private" world Mozilla claims they're pushing towards.
Chrome extensions only support the 'chrome' namespace, while Firefox supports 'chrome' and 'browser', but Safari 14 only supports 'browser'. So our extension had been using the 'chrome' namespace which worked under Firefox, but now needed to be converted. 'chrome' uses callback functions, while 'browser' uses Promises. So you have to port your Chrome extension to use 'browser' and use the following polyfill: https://github.com/mozilla/webextension-polyfill
Here's some incompatibilities between Chrome and Firefox to consider: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/Web...
Also had some html/css glitches to fix in Safari. Some other issues others have mentioned such as notifications and webRequest APIs.
if ( self.browser instanceof Object ) { self.chrome = self.browser; } else { self.browser = self.chrome; }
Instead of using a polyfill like that one https://github.com/mozilla/webextension-polyfill?
There's a nice polyfill by Mozilla so you can use their promise interface in Chrome but it was missing some important apis last I checked (sessions and optional permissions). https://github.com/mozilla/webextension-polyfill
https://github.com/mozilla/webextension-polyfill
The biggest challenge for me was addressing browser incompatibilities and Firefox bugs. This is a big one:
https://bugzilla.mozilla.org/show_bug.cgi?id=1193394
Another is that Firefox doesn't fire blur events when DOM elements are removed or hidden.
The Firefox approval process is slow. Mine took 3 months the first time, < 10 days the second time, and this third time it's taking over a month.
Chrome's reviewal process is really nice. It usually takes <30 minutes.