2

I currently have a Firefox extension/plugin combo that works well, and was written with a combination of NPAPI (Firebreath) C++ code and Javascript. The extension works by defining a browser overlay (overlay.xul/overlay.js) that is loaded on every webpage via a script src="overlay.js" tag.

I need to adapt it for the upcoming changes for Firefox Webextensions and deprecation of XPCOM/XUL.

From what I understand, Webextensions will be primarily Javascript based. How would I be able to continue using the C++ portion of my extension? Note that porting the C++ NPAPI library to Javascript would be a non-starter for various reasons.

Phenglei Kai
  • 413
  • 5
  • 14
  • I'm not sure about Webextensions but you can move to js-ctypes https://developer.mozilla.org/en-US/docs/Mozilla/js-ctypes – Noitidart Aug 26 '15 at 06:29

1 Answers1

0

You have to use Native messaging to keep some part of your code in C++.

Be aware only the background script can directly communicate with your native/C++ code. But these messages can later be dispatched to your content scripts.

The communication between your C++ code and the background script is through the stdin/stdout.

There is a nice example between python script and web-extension on github: https://github.com/mdn/webextensions-examples/tree/master/native-messaging

OlivierM
  • 2,820
  • 24
  • 41