FireFox插件WebExtension API-打开本地文件/应用程序 [英] FireFox Addon WebExtension API - open local file / application

查看:135
本文介绍了FireFox插件WebExtension API-打开本地文件/应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用WebExtension API编写一个mozilla firefox扩展.我无法使用WebExtension API来找到源代码.

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);
}

使用WebExtension API编写mozilla firefox扩展的源代码如何?

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

推荐答案

很遗憾,我无法使用您建议的解决方案,因为必须在本地PC上对Addon进行附加设置.我想防止进行这些设置.我对解决方案感兴趣,在该解决方案中,可以直接从浏览器中执行变量路径.例如,应该在其中打开一个文件夹或本地文件

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

不能仅通过webextensions来完成(webextensions在某种程度上是为了防止这种情况),您还必须安装一个本机应用程序,并使用

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.

这篇关于FireFox插件WebExtension API-打开本地文件/应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆