简体   繁体   English

覆盖/嵌入Firefox扩展中的插件SDK以修改panel.js

[英]Override/embed addon SDK in a Firefox extension to modify panel.js

I use the Addon SDK to display a Panel. 我使用Addon SDK来显示面板。 It's working fine, but I would like to set the noautohide property to true , so the panel will not closed automatically when user clicks outside the panel. 它工作正常,但我想将noautohide属性设置为true ,因此当用户在面板外单击时,面板不会自动关闭。

I managed to access to the panel object using "chrome" authority but I am afraid of the red mark "experimental" ;-) 我设法使用“ chrome”权限访问面板对象,但是我怕红色标记“ experimental” ;-)

So I would like to edit panel/utils to expose the noautohide property. 因此,我想编辑panel/utils以公开noautohide属性。 Is it possible to "override" or "embed" my edited file in the extension package? 是否可以“覆盖”或“嵌入”扩展包中的已编辑文件?

Unfortunately, there is no supported way of doing this (that I know). 不幸的是,没有(我知道)支持的方法。 Searching the SDK sources for noautohide without any results seems to confirm this. 在SDK源中搜索noautohide没有任何结果似乎可以确认这一点。

Personally, I'd use the require("chrome") -and-get-the-XUL-element workaround for now (but keep in mind that there could be more than a single browser window), or just not implement it at all. 就个人而言,我现在将使用require("chrome")并获得XUL元素的解决方法(但请记住,可能存在多个浏览器窗口),或者根本不实施它。

I would advice against patching the SDK and/or "embedding" a patched panel library. 建议不要修补 SDK和/或“嵌入”已修补的面板库。

The former would require to use a bundled SDK instead of the built-in SDK and seeing all the changes that go into each Firefox release, you'd likely have to re-package your XPI with every major Firefox update. 前者需要使用捆绑的SDK而不是内置的SDK,并查看每个Firefox版本中的所有更改,因此您可能必须将XPI与每个主要的Firefox更新重新打包在一起。 Also you're not allowed to host add-on on AMO that bundle a patched SDK. 另外,您也不能在捆绑了已修补SDK的AMO上托管附加组件。

The latter option of "embedding" just the panel lib has the same maintenance problems. 仅嵌入面板库的后一种选项具有相同的维护问题。 Also, it isn't exactly easy to extract/clone the just the panel library from the SDK... At the very least you'd have to clone sdk/panel.js and sdk/panel/*.js maybe even more. 此外,它是不太容易提取/从SDK克隆只是面板库...在你不得不克隆最起码sdk/panel.jssdk/panel/*.js甚至更多。

It might be helpful if you filed a feature request . 如果您提出功能请求 ,可能会有所帮助。

Rather than patch it what you can do is as addEventListener for popuphiding and do event.stopPropagation(); 无需修补它,您可以作为addEventListener进行popuphiding并执行event.stopPropagation(); popuphiding and event.preventDefault(); event.preventDefault(); . Then just add a close button that on click removes that listener and then hides the panel. 然后只需添加一个关闭按钮,单击该按钮即可删除该侦听器,然后隐藏该面板。 I couldn't get arouund the noauthohide any other way: 我无法以任何其他方式唤醒noauthohide

Avoid panel to autoHide in Firefox extension 避免面板自动隐藏在Firefox扩展中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM