Hello.
I’m trying to build a firefox extension that displays a popup when you click the button on the toolbar and also runs a batch script (that subsequently runs a python script) on my local machine using native messaging.
I was able to get native messaging to work on the click of the button (without the popup). However, once the popup is set, the popup runs but native messaging fails to work i.e. the batch script does not execute. This is for both connection based and connection-less messaging.
Here’s what I’ve tried and the results: note that in all cases, the popup is opened in the click listener for the toolbar button
Setting popup in manifest.json: in this case, batch script doesn’t execute at all.
Setting popup in the listener for the toolbar button: batch script runs once, native messasging fails on subsequent runs in connection based messaging; batch script fails to execute on connection-less messaging. Basically, native messaging executes once.
Setting popup on window onload listener: batch script doesn’t execute at all.
Native messaging is executed through a background.js file that is set as background script in manifest.json. Popup is also set in this file if not set in manifest.json.
I’ve tried calling the functions like this;
browser.runtime.sendNativeMessage();
and like this;
browser.extension.getBackgroundPage().browser.runtime.connectNative();
Wasn’t able to find a solution on google either. Would really appreciate assistance on this.