Is there a way to port a chrome extension to other browsers?

12,618

Solution 1

It depends on the type of the extension, but not really. To answer your question more clearly, you need to specify what your extension is about: modify some pages (like userscripts/userstyles), extend browsers' features, or something else.

There are a few portability notes, however, that could help you to simplify this process:

  1. Don't write browser specific code. In some modern browsers you're able to use HTML5 features, like Web SQL Database API. It is difficult to emulate such behaviour on IE, for instance.
  2. Keep your JavaScript modular; don't use vendor specific JavaScript methods, and your code will be portable and will not rely on TraceMonkey or V8;
  3. Separate HTML from CSS and Javascript, don't make your code dirty and complicated.

Solution 2

Jumping in a bit late.

Our company - Slice Factory (full disclosure here!) does provide a browser extension conversion service: http://gallery.extensionfactory.com/labs/conversion/ In most cases your chrome extension will work seamlessly in FF and Safari.

The service is still in beta trial, and Firefox conversion is working better than Safari one. I can't fully disclose what's our technical solution, but this being an SO answer, I can add a few details: we have re-developed a full javascript api stack that mimics most of chrome extension APIs for Safari and Firefox; in Firefox we base our work on JetChrome. Plus we have wrappers that re-package the chrome extension adding our library and rewriting manifests and so on.

Beyond that, it's mostly a few good ideas, trial and error, and a LOT of development time.

As an example: Safari 5.1 just introduced a popup corresponding to Chrome's browser_action, but we have already an alternative solution that works for previous versions. Firefox does not support HTML5 WebSQL, but we have an API for it. We also provide a way to bring webapps to FF, and soon to Safari. The objective is to have Chrome API as a reference, and mimic it on all the other browsers.

Without pushing you towards our solution, I might add that the time to fully cover the Chrome API on both Safari and Firefox is probably not worth it - unless you plan to convert several extensions. So for just one or two extensions I would advise making your code as modular as possible, and just creating three extensions - or trying our service!

Share:
12,618
David
Author by

David

Student and Google Chrome extension developer

Updated on June 05, 2022

Comments

  • David
    David almost 2 years

    Is there a way to port a chrome extension to other browsers, without having to entirely re-write the code? My chrome extension uses the browser_action command to open "popup.html" in the extension window...

    Update: I found adblockforchrome port.js and found it only somewhat helpful for porting to Safari...

  • user2012801
    user2012801 almost 14 years
    Why would you care about IE compatibility? It doesn't support extensions.
  • Stefano
    Stefano over 12 years
    Oh, and for IE there are webslices. We use them for another one of our products as a 'surrogate' :)
  • Stefan Schmidt
    Stefan Schmidt over 12 years
    Just tried your service, but sadly it didn't work. (IDs: hcieonlgpadegedlcpdhndifhaeahajp, bkeiokdfjgnaglohebonlmpimnpinahd)
  • Stefano
    Stefano over 12 years
    @StefanSchmidt unluckily there are always some limitations! The first one does not work because they search for an element in the page before the page is created. It's lucky it works in chrome, actually. The second one converts and works well in Firefox; it does not convert in safari because of an unsupported image format, I fixed that but it's likely it will not work because of separation of cookies between popup and pages in Safari. If you have further interest, please contact me through the email at the bottom the website page!
  • Ofir Hadad
    Ofir Hadad over 11 years
    @Stefano Your chrom convertor is a great thing! You wrote "Oh, and for IE there are webslices. We use them for another one of our products as a 'surrogate'" Where is this solution for IE? I have a chrome extension that i want to port to IE.
  • Stefano
    Stefano over 11 years
    @ofear thanks!! sorry the webslice solution is not automatized yet, so we can't easily provide it. Webslices have very limited interaction so it's not a good overal solution, and ofter requires re-writing most of your extension with a different approach. IE10 might and Win8 will change this, we thought our efforts were better aimed at more sustainable solutions so that's were we are researching now. Some ActiveX wrapper solutions exist for IE 8/9, but we don't provide that solution.
  • Kristijan
    Kristijan over 10 years
    @Stefano I tried your service multiple times - but I always get a 504 gateway time-out (for days now).
  • Stefano
    Stefano over 10 years
    @Kristijan I have moved on to other projects since, and the company is now focused on other products; but you could try asking directly there: builder.extensionfactory.com/crm/request_create Otherwise, there are other solutions that came out since - though most require some code modifications afaik...
  • Sandeep J Patel
    Sandeep J Patel about 7 years
    @Stefano i tried to open the conversion url but it seems to be no more available :(
  • Stefano
    Stefano about 7 years
    hello @SandeepJPatel, that was 3 years ago indeed ;-) I don't even work in that company any more and i'm sure there are other alternative now!