1. 10

I would like to write a set of browser extensions for better “knowledge work”, i.e., things to do with organizing tabs, managing history, annotating webpages, saving excerpts (either to disk or some service). These are mainly for my personal use, but I would like to make them public once they are robust enough.

I have never written a browser extension before, but am an experienced programmer. I am wondering what the major difference in extension capability and programmer friendliness are between the various browsers? What are the major gotchas and pitfalls I should be aware of? Is one clearly better than the other? I am mainly trying to decide between Chrome and Firefox.

I’d be particularly interesting in hearing from people who have developed extensions for multiple browsers and knowing what their experience has been.

  1. 4

    I wrote one extension from scratch and contributed a lot of code/bugs to another. My advice would be to support both Chrome and Firefox. It’s pretty easy to do if you use Mozilla’s webextension-polyfill from the start but quite a gargantuan task if you try to add this after the code is already written (because the polyfill isn’t perfect and some small differences remain here and there).

    I am wondering what the major difference in extension capability and programmer friendliness are between the various browsers?

    Mozilla has more APIs and they are better designed (they’re more recent so they were able to rely on newer JavaScript features such as promises).

    What are the major gotchas and pitfalls I should be aware of?

    I can’t think of any webextension-specific gotchas. Try to setup a testsuite early, testing webextensions is pretty hard.

    Is one clearly better than the other?

    In my opinion Firefox is better than Chrome. As I said, it has more APIs, Mozilla folks seem to listen a bit more to what their community tells them, don’t plan on deprecating their APIs yet (while Chrome does, e.g. WebRequests). In my opinion Mozilla is also a more ethical choice and that’s why you should support them. The only thing going for Chrome IMO is that you’ll get more users - I realeased my extension to the Mozilla addon store about 4 months before I released it on the Chrome Web Store and I still have twice as many users on Chrome than I do on Firefox.

    1. 3

      Chrome and Firefox (and edge and opera) have similar enough models that a portable extension is quite viable.

      My notes from last time I tried this:

      • Extensions are javascript (+ html/css if you have more UI than a single button)
      • Extensions have a manifest file listing the permissions they need; only APIs listed there are available.
      • There are multiple execution contexts in an extension. Communication between contexts is entirely via global message broadcast.
      • ‘Content scripts’ are javascript run the usual way in a web page. They have a different global scope to your extension (this protects your extension from malicious pages replacing e.g. XMLHTTPRequest with a malicious copy that siphons data to their servers).
      1. 2

        I’m working on couple of browser extensions, coincidentally also knowledge-related!

        • grasp, tool for web clipping into org-mode files on my disk
        • promnesia tool for enhancing my browsing history, integrating it with annotation, web services, IM, etc

        Like few people pointed out, most browser APIs are same in Firefox and Chrome; and I also was pleased to find out that even on mobile Firefox I can use exactly the same code with only few unavailable APIs (see webpack config and runtime check)

        Testing can also be mostly abstracted away by selenium, e.g. most of my end-to-end tests are running both against firefox and chrome.

        P.S. I’d be very interested to know about more specific usecases you want to support in your extensions! I research and write about knowledge management a lot, so I feel like it’d be valuable to discuss if you’re at the point of willing to write your own extension – very few people bother with that :) Also feel free to ping me if you got question about something webextension specific – happy to help.

        1. 1

          Thanks for the advice! I was actually inspired to go down this route by seeing the things you’ve been building. I think my interests are similar, but not quite the same.

          There are two main extensions I want to build. First, a way to archive and mark up webpages. There is a Chrome extension called Weava that does something similar, but it’s SaaS and I doesn’t seem to have a convenient export format.

          Second, I would like better history tools. In particular, often have the problem that I read an article or page and want to link to it in a blog post (or similar), but I’ve forgotten how I found it. I’d like an extension that can maintain “chains” of followed links so that I can always look up how I found something.

          I’m happy to get in touch and consider collaborating if you’re interested.

        2. 2

          I recommend developing for firefox first with the webextension-polyfill. Doing it that way in combination with using web-ext makes it similar to developing a website. Auto refresh, both chrome and firefox supported.

          I say you should support firefox but you will straight up have more users on your chrome version.

          1. 1

            I would like to know this too. I am actually starting a project on a Firefox extension right now but was curious as to how hard it is to migrate it to chrome if I decided to.

            1. 2

              Firefox, chrome and edge have almost exactly the same set of APIs. “WebExtension” standard on MDN has more.