How to convert existing web extensions for Safari
developer.apple.com
developer.apple.com
Vimium and uBlock Origin are pretty much the only two plugins keeping me from switching away from Chrome/Firefox to Safari.
Given all the hype around Safari’s performance on new M1 Macs (and the fact that only Safari supports Apple Pay), I’d love to have parity on these two extensions extensions. It seeems like Web Extensions will not provide enough to fully support uBlock Origin, but maybe their Content Blockers will be a close enough approximation.
At the very least, I hope that Safari will gain a larger userbase from these changes, regardless what I choose to use. Having multiple large, evenly distributed userbases will only make web developers think more about Chrome-first or Chrome-only development.
Also, generally speaking, the way Safari implements this means that the extension passes on the block list to the browser and Safari itself implements the blocking. This means,
1. It is more private since the extension does not have access to your webpage. 2. It is faster because Safari can do it natively and it is not done in JavaScript.
+1, especially uBO
Does anyone know the latest on uBO coming to Safari (or not)?
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/Web...
I could see a privacy case in not letting any and every extension have access to all requests.
People keep making that argument, and I keep having to correct this.
Their webRequest is not blocking but it does support _observing_ all network requests[1], just as is planned with ManifestV3.
The privacy argument can't and shouldn't be used to justify the removal of the blocking capability from the webRequest API.
---
[1] https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/Web...
Safari Mac does have JavaScript extensions too (iOS only supports content blockers), and everything gorhill says does apply to them. And indeed some vendors ship both a content blocker and a Safari JavaScript extension in the same Mac app (though each one has to be enabled separately in Safari). Thus, it could be argued that this is a distinction without a difference. But from a technical perspective they're entirely different technologies.
The macOS 10.15 SDK did add an API for a Safari JS extension to receive information from a content blocker embedded in the same Mac app, allowing for example the extension to show stats for blocked resources: https://developer.apple.com/documentation/safariservices/sfs...
My personal theory is that Safari content blockers were designed primarily for iOS, which has no Safari web extensions, and the Mac side was a bit of an afterthought.
What reason does Apple give for not allowing blocking, then?
I am unfamiliar, so please feel free to correct me. Thanks for uBO!
Documentation about what can be observed or not is all available online, there is no need to make any assumption:
Firefox: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/Web...
Chromium: https://developer.chrome.com/docs/extensions/reference/webRe...
That should answer all questions regarding what can be observed.
I can also choose to enable an extension that does have JavaScript and know that it could observe what I browse.
But when the Safari 14 GM release came around, I couldn't justify spending $100 per year just to get my extension on Safari. My goal is to test my product ideas. Chrome gives me plenty of installs to do that, and Safari's user base is too small on the desktop. Adding Safari also means that I have to manage another release system, deal with all of Apple's app store approval quirks, and support customers on a new platform. The added $100 / year just adds to the trouble.
I still think Safari supporting WebExtensions is a big win for the web platform. When I do scale and when Apple sorts out the new platform quirks, I think I will pay the $100 per year and all the added time and technical costs.
[1] https://twitter.com/rayshan/status/1292270249362956288
[2] https://finance.shan.io/stock-inspector-discover-new-compani...
I'm surprised Apple put this barrier up since it certainly would have scared me away from iOS development as a poorer/newer developer. I guess Apple's happy with amateurs building but doesn't want to deal with their apps in the store. Maybe a compromise would be letting people self-distribute free apps without paying the $100?
Not sure what you mean about poor design or maintenance. The lower barrier to entry means there are many more options and often unmaintained extensions get forked. (If their license is permissive, which is more often the case when the creator doesn't have to pay $100 per year.)
However I’d also wondered if there’s a scenario where several independent devs might band together and use a single organisational dev account to ship their own apps. Obviously trust (between devs who are otherwise strangers to each other) is an issue here but I’m sure you’re not the only one in that scenario.
Forcing developers to pay is the most developer- and user-hostile thing they could do, and is the main reason I don’t use Safari anymore (there just isn’t any worthwhile extensions for it).
What I’d bet most people (including myself) do is search for extensions (assuming you don’t already know the exact one you want). My experience has almost always been that the extension I want isn’t available for safari (just chrome and Firefox), or is a shitty/old version of the chrome one.
So even if the $100 keeps some more junk out than on chrome, I still don’t get to use the extensions I want and the ones that are available aren’t great (albeit better than junk).
Google requires developers to pay them $5, once, before they can upload extensions to the web store.
They’re just covering the fees to prove you’re a person/developer, and basically nothing more.
Thank you!
They make reporting bugs impossible because you can't just reproduce it by updating your OS again. Native app messaging is done through shared data which forces you to poll for updates.
Urggh. I wish they could just own up to the mess (like Microsoft did) and fully move to Web Extensions, including native app messaging.
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.
According to the documentation, "Safari web extensions support both the chrome.* and browser.* namespaces." https://developer.apple.com/documentation/safariservices/saf...
Thing is Safari is a nice browser to use, but without uBlock Origin it's a non-starter for me, all these 'content blocker' solutions are either bloated or nowhere near as good as uBlock Origin.
In practice, well, just search this site for threads about it. I'm not sure, like you indicate, it's worthwhile for the browser ecosystem.
If you have an existing Mac app, it might be worth it, but personally, there's no chance that I would bother porting my own standalone WebExtensions to Safari under the current system, whereas I went to the trouble of doing so ($99/year fee and all) for the legacy framework, even though I don't really use Safari. Maybe Apple is OK losing large numbers of smaller extensions, but for me, it just means I'd never seriously consider Safari as an alternative to Firefox or Chrome.
Here’s what I need to port Chrome extension to Firefox:
1. Upload a zip file
2. Fill in very few additional details
3. Wait for review
Here’s what it takes for Safari: 1. Own a Mac
2. Download 12GB of XCode
3. Run the conversion tool (this is the point that everyone talks about)
4. Well done, now you have an XCode project you’ll have to maintain
5. Pay $99/yearly
6. Fill pages of senseless details and read scary-sounding notices about encryption because your extension is enabled on HTTPS
7. Wait for review
8. Get denied because of an “entitlement” that the conversion tool added for you
9. Wait for review
10. Fix a number of slight incompatibilities you’ll find over time, from basic features that other browsers have had for a long time to the APIs actually not being standard.That one's really simple, but doing the Firefox port first seems to have ironed out most of the compatibility issues. Mostly APIs with newer versions where Chrome is the only one to support the old API.
But just exploring web extensions a bit (this was my first time interacting it), it feels like supported features differ quite a bit between browsers. Chrome has the lead here, and Safari seems 'minimal' in comparison. UI elements can also behave very differently between browsers.
Apple is dead-set on having you use the App Store to distribute even web extensions. The converter works fine, but just this way of doing things does bring along a bunch of frustration for unfamiliar devs. There was a Twitter thread on this recently started by a member of the Safari team, which gives an idea: https://twitter.com/jensimmons/status/1338558758025367553
My extension for those interested: https://github.com/nishanthvijayan/CoderCalendar-Extensions/
uBlock Origin makes this trivial—it’s literally a click on the extension logo and then one more tap.
iOS Safari already has “Turn off Content Blockers” and “Website Settings” per website, but I haven’t been able to find a menu or app that makes it convenient to toggle JavaScript on a page.
I use a 4 year old iPhone with a dying battery and aging processor. The web is slow and made much faster without JavaScript. It’d be great to have a toggle for this.
The notifications API is also missing in Safari, so extensions must use the native messaging API to show notifications from the native app extension.
This leads me to think that if Apple were to add support for something like the webRequest API, it'd likely be via the native half of the extension API and potentially even Swift-only so there can be stronger guarantees on things like execution time. This may also allow users of the API to better take advantage of multithreading for more complex operations.
I may be misunderstanding something about how the webRequest API is traditionally implemented that deals with these concerns however, in which case feel free to correct me.
This is in the name of security. Whether you believe that is up to you, but personally I don’t even install extensions that require access to all of my tabs, let alone something that can read pure requests (with the exception of uBlock)
The only extension I truly need before I use safari again.
Never. The Safari team already (wrongly) feels that their Safari-specific "content blocker" API is adequate, and moreover, Google Chrome has announced the deprecation of the webRequest blocking API used by uBlock Origin, so it almost certainly won't be ported to Safari, and it's an open question how long uBlock Origin will even last on Chrome in the future.
Ad/tracker blockers based on Apples content blocker framework absolutely do work.
So when I said funny, I meant funny as in, “this meat smells funny”.
Please refrain from writing "this meat smells funny" comments on HN. You could go around commenting on typos too, which happen all the time, but that's not at all helpful.
For me the issue is that Safari garbles the sound when using Google Hangouts and Whereby. Having to open another browser just to use those services, is pretty annoying.
I wanted to point out that it is Apple sharing how to modify your extensions to work with Safari, as opposed to Apple sharing how they modified Safari to work with WebExtensions.