Using a plugin generated with Firebreath in a Firefox Extension?

你。 提交于 2019-11-29 12:25:10
Wladimir Palant

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

Nick Sawadsky

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

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