Is there a way to port a chrome extension to other browsers?
Asked Answered
R

4

20

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...

Rent answered 11/8, 2010 at 14:17 Comment(0)
B
5

Apple provides some guidance on how to port convert a Chrome extension to Safari, but the problem you're going to run into is that each browser has a different set of allowed functionality for extensions. Even with Chrome to Safari, there are things you could do in Chrome you can't do in Safari, and visa versa.

Biblio answered 14/8, 2010 at 8:58 Comment(0)
E
4

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.
Extravasation answered 11/8, 2010 at 17:7 Comment(1)
Why would you care about IE compatibility? It doesn't support extensions.Jermainejerman
P
4

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!

Pilarpilaster answered 15/9, 2011 at 14:18 Comment(9)
Oh, and for IE there are webslices. We use them for another one of our products as a 'surrogate' :)Pilarpilaster
Just tried your service, but sadly it didn't work. (IDs: hcieonlgpadegedlcpdhndifhaeahajp, bkeiokdfjgnaglohebonlmpimnpinahd)Ballyhoo
@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!Pilarpilaster
@Pilarpilaster 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.Unhorse
@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.Pilarpilaster
@Pilarpilaster I tried your service multiple times - but I always get a 504 gateway time-out (for days now).Repetitive
@Repetitive 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...Pilarpilaster
@Pilarpilaster i tried to open the conversion url but it seems to be no more available :(Doolittle
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!Pilarpilaster
B
0

Yes, it's possible with Webextension API using webextension-polyfill.

I made use of it to build this where I only had to change the callback methods to Promises and using browser.something instead of chrome.something to call the browser APIs.

Bronze answered 13/1, 2019 at 13:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.