FireFox Addon WebExtension API - open local file / application

有些话、适合烂在心里 提交于 2019-12-08 01:50:35

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/41680643/firefox-addon-webextension-api-open-local-file-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!