How to run a command line program in Firefox Webextensions?

I would like to run a command (exe somewhere on the disk) with arguments in a simple WebExtensions addon and possibly get it stdout. Is there a way to do this in WebExtensions since legacy APIs are deprecated?

+5
source share
1 answer

This blog post mentions as - https://blog.mozilla.org/addons/2016/06/09/webextensions-for-firefox-49/

Read the runtime.connectNative section. They speak:

runtime.connectNative

This API allows you to interact with other processes in the host operating system. It is a widely used API for password managers and security software that needs to communicate with external processes.

To communicate with your own process, this is a two-step process. First, your installer needs to install the JSON manifest file in the appropriate location on the target computer. This JSON manifest provides the link between Firefox and the process. Secondly, the user installs the add-in. Then the add-in can call connectNative, sendNativeMessage and other APIs:

 chrome.runtime.sendNativeMessage('your-application', { text: "Hello" }, function(response) { console.log("Received " + response); }); 

Firefox will start the process if it has not already started, and passes the commands to the process. Follow along with runtime.connectnative's progress in bugzilla.

+3
source

All Articles