2

I wanted to know the best way to bring a Chrome extension on another browser, use Crossbrowser , re-coding is not an option as its very large.

Haibara Ai
  • 10,703
  • 2
  • 31
  • 47

3 Answers3

2

the best way to port a chrome extension is to look into WebExtension: https://wiki.mozilla.org/WebExtensions

https://developer.mozilla.org/en-US/Add-ons/WebExtensions

Firefox already is on its way to support it: https://blog.mozilla.org/addons/2015/08/21/the-future-of-developing-firefox-add-ons/

and also Microsoft Edge has promissed to support the chrome APIs and already supports some chrome.* apis ive tried: http://www.winbeta.org/news/new-microsoft-edge-browser-can-use-chrome-and-firefox-extensions

Hopefully in a few months this will all work in production. Of course your code should still be cross-browser (another answer here has some tips) and this answer covers support for special extensions API.

Zig Mandel
  • 19,571
  • 5
  • 26
  • 36
  • Thank you ! Yes we ve to wait Microsoft , and for FireFox i've already find SDK ADDON and it's work very well ! – Arthur Cretté Sep 22 '15 at 13:28
  • 1
    @ArthurCretté and Zig here is MDN documentation on WebExtensions some of it alreayd landed and is pretty usable: https://developer.mozilla.org/en-US/Add-ons/WebExtensions – Noitidart Sep 22 '15 at 15:08
  • 1
    Thank You, i've already saw that, but my english is to bad to understand very well... But I find a topic in French for SDK addon, and it's very nice ! Thanks a lot ! – Arthur Cretté Sep 22 '15 at 15:14
  • 1
    @Noitidart ive added the link to the answer. – Zig Mandel Sep 22 '15 at 15:16
  • @ArthurCretté if you need help there a bunch of french members on the mozilla irc channels that can help you out: here is an html5 irc client to the channel: https://client00.chat.mibbit.com/?url=irc%3A%2F%2Fmoznet%2Fextdev and here is the firefox webextensions help channel: https://client00.chat.mibbit.com/?url=irc%3A%2F%2Fmoznet%2Fwebextensions – Noitidart Sep 22 '15 at 20:34
  • @Noitidart Thank You that's very cool !Love the solidarity of web users! – Arthur Cretté Sep 23 '15 at 08:02
  • @ArthurCretté here is an awesome article step by step to help you write it, with copy paste code: https://hacks.mozilla.org/2015/09/lets_write_a_webextension/?utm_source=html5weekly&utm_medium=email – Noitidart Sep 23 '15 at 16:01
  • This could use an update. – Makyen Jun 11 '17 at 18:02
0

The argument here is based on the type of the extension but in most cases it is not the case that one would be able to transfer the extension from one browser to another. To answer the argument here, you need to specify what your extension is about, if it’s only related to modifying some pages (like userscripts/userstyles), extend browsers' features, or something else, as this does play a difference in the subject. 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.

Hope this helps :)

  • I do not know the function of the extension, nor what it does on the page. But I wanted to know if it was easier to go through Crossrider (for example) or re-code the extension by naviguateur? I wear a FireFox extension on Chrome, thanks to the SDK-FF, but Internet Explorer is another problem, which is why I wanted to know if a Crossbrowser would be more practical – Arthur Cretté Sep 22 '15 at 09:06
  • I think in this case using a Cross browser would yes be more piratical :) – Bendan Schembri Sep 22 '15 at 09:08
0

I created this library to make crossbrowser way to write one code that will work in both FF/Chrome. But it based on promises behaviour (FF way). So it will be helpful for those who starting to write new extension. In your case you'll need to rewrite all callback behaviour to promise behaviour, but after that done, code will be much cleaner.

https://github.com/lawlietmester/webextension

Keep in mind that some APIs has absolutely different realizations in FF and Chrome, like Proxy API (not Proxy object).

Rustam
  • 1,875
  • 2
  • 16
  • 33
  • Please explain how this differs from the [official Mozilla package](https://github.com/mozilla/webextension-polyfill) that polyfills `browser.*` into Chrome? – Makyen Jun 11 '17 at 18:01
  • Also, while interesting, how does this affect porting an already existing Chrome extension to Firefox, or other browsers? This would be useful for porting from Firefox (and other `browser.*` based browsers) to Chrome, but does not make it easier to port from Chrome to others. – Makyen Jun 11 '17 at 18:04
  • @Makyen For example you can use runtime.onMessage.addListener with promise return in Chrome. Mozilla realization does not allow that. Also read syntax features - it will be expanded in future – Rustam Jun 11 '17 at 20:13