在 Firefox 扩展中使用 Firebreath 生成的插件?

发布于 2024-11-11 01:12:01 字数 223 浏览 6 评论 0 原文

是否可以在 Firefox 扩展中使用由 Firebreath 制作的 .dll?

目前,我正在尝试移植为 Google Chrome 制作的扩展,该扩展使用 javascript 获取文档的 HTML,然后从 .dll 调用函数并将文档的 HTML 作为参数传递。然后 .dll 保存文件并启动程序。

有没有一种简单的方法可以将此功能移植到 Firefox?或者我必须使用 XPCOM 重写代码吗?

Is it possible to use a .dll made with Firebreath in a Firefox extension?

Currently, I am trying to port an extension I made for Google Chrome that uses javascript to get the HTML of the document, and then calls a function from the .dll and passes the HTML of the document as a parameter. The .dll then saves the file and launches a program.

Is there a simple way to port this functionality over to Firefox? Or will I have to rewrite the code using XPCOM?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

淡墨 2024-11-18 01:12:01

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

转身泪倾城 2024-11-18 01:12:01

对于简单的功能,我还推荐 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

寄风 2024-11-18 01:12:01

是的,您可以使用 firebreath dll 作为 Firefox 扩展。对于 Firefox,您可以使用相同的 javascript,但需要进行一些修改;对于 HTML,您必须使用 XUL 。您必须在覆盖默认 firfox 的 browser.xul 的 XUL 中加载脚本。

overlay chrome://browser/content/browser.xul chrome://Yourproject/content/Youroverlay.xul

在 Youroverlay.xul 内,您可以添加以下行来嵌入 Firebreath dll

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/"?>
<overlay id="myOverlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml">
<script type="application/javascript" src="chrome://Yourproject/content/background.js"/>
    <vbox style="height:0;">
        <html:embed type="application/x-myproject" id="myproject1" style="height:0;"/>
    </vbox>
</overlay>

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

overlay chrome://browser/content/browser.xul chrome://Yourproject/content/Youroverlay.xul

Inside Youroverlay.xul, you can add the below line to embed Firebreath dll

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/"?>
<overlay id="myOverlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml">
<script type="application/javascript" src="chrome://Yourproject/content/background.js"/>
    <vbox style="height:0;">
        <html:embed type="application/x-myproject" id="myproject1" style="height:0;"/>
    </vbox>
</overlay>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文