Net_Hans
Net_Hans

Reputation: 185

FireFox Addon WebExtension API - open local file / application

I would like to write a mozilla firefox extension by using the WebExtension API. I couldn´t find a source code using the WebExtension API for my purposes.

var {Cc, Ci} = require("chrome");  // Low-Level API Imports (For Launcher)
var prefs = require("sdk/simple-prefs").prefs;

var app = "C:\\abcd\\test.exe";
var file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
file.initWithPath(app);
var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
 
if (file.exists()) {
	process.init(file);
	var params = prefs["param"];
	var args = ["" + params +  ""];
	process.run(false, args, args.length);
}

How does a source code for writing a mozilla firefox extension by using the WebExtension API look like?

Upvotes: 2

Views: 1470

Answers (1)

erikvold
erikvold

Reputation: 16528

Unfortunately I can´t use your suggested solution, because there have to be made settings on the local PC additional to the Addon. I would like to prevent making these settings. I am interested in a solution, where a variable path can be executed directly out of the Browser. For example, a folder or a local file should open there

can't be done with webextensions alone (webextensions were in part meant to prevent this), you'd have to have a native app installed as well, and message pass to it, using the native messaging api that was mentioned.

Upvotes: 2

Related Questions