在 Firefox 扩展中使用 Firebreath 生成的插件?
是否可以在 Firefox 扩展中使用由 Firebreath 制作的 .dll?
目前,我正在尝试移植为 Google Chrome 制作的扩展,该扩展使用 javascript 获取文档的 HTML,然后从 .dll 调用函数并将文档的 HTML 作为参数传递。然后 .dll 保存文件并启动程序。
有没有一种简单的方法可以将此功能移植到 Firefox?或者我必须使用 XPCOM 重写代码吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
XPCOM 对于简单的事情来说太复杂了,这就是 Firefox 4 及更高版本具有 js-ctypes 的原因(请参阅 https: //developer.mozilla.org/en/js-ctypes 了解概述和 https://developer.mozilla.org/en/js-ctypes/Using_js-ctypes#Calling_Windows_routines 为例)。这使您可以轻松加载 DLL 并调用导出的本机函数。如果你确实需要使用这个 DLL 作为 NPAPI 插件,事情会变得更加复杂,因为你需要一个窗口来加载插件,而 Firefox 与 Chrome 不同,没有专门的背景窗口。但我猜你只是将 DLL 变成了插件才能在 Chrome 中使用它。
关于找到要与 ctypes.open() 一起使用的 DLL,请参阅我的答案: 将二进制组件引用到 js-ctypes
XPCOM is too complicated for simple things which is why Firefox 4 and above has js-ctypes (see https://developer.mozilla.org/en/js-ctypes for an overview and https://developer.mozilla.org/en/js-ctypes/Using_js-ctypes#Calling_Windows_routines for an example). This allows you to load the DLL and call an exported native function easily. If you really need to use this DLL as an NPAPI plugin things get more complicated because you need a window to load the plugin into and Firefox unlike Chrome doesn't have a dedicated background window for that. But I guess that you only turned your DLL into a plugin to be able to use it in Chrome.
On locating your DLL to use with ctypes.open() see my answer here: Reference a binary-component to js-ctypes
对于简单的功能,我还推荐 js-ctypes。它易于使用并提供良好的隔离(因为页面上的脚本无法访问导入的库)。
如果您确实需要从任何页面访问 NPAPI 插件,标准方法似乎是创建一个扩展并修改每个页面的 DOM 以包含该插件:
可编写脚本的 NPAPI 插件不适用于 Firefox
For simple functionality, I also recommend js-ctypes. It is easy to use and provides good isolation (since scripts on the page cannot access the imported library).
If you really need to access an NPAPI plugin from any page, the standard approach seems to be to create an extension and modify the DOM of each page to include the plugin:
Scriptable NPAPI plugin doesn't work with Firefox
是的,您可以使用 firebreath dll 作为 Firefox 扩展。对于 Firefox,您可以使用相同的 javascript,但需要进行一些修改;对于 HTML,您必须使用 XUL 。您必须在覆盖默认 firfox 的
browser.xul
的 XUL 中加载脚本。在 Youroverlay.xul 内,您可以添加以下行来嵌入 Firebreath dll
yes you can use a firebreath dll as an firefox extension. you can use the same javascript with some modifications for Firefox and for HTML you have to use XUL. You have to load the script in a XUL that overlays default firfox's
browser.xul
Inside Youroverlay.xul, you can add the below line to embed Firebreath dll