简体   繁体   English

从传统的基于XUL的插件中访问Add-on SDK?

[英]Access the Add-on SDK from within a traditional XUL-based add-on?

I have a large and complex XUL-based addon for which I need to use a few functions from the Add-on SDK. 我有一个庞大而复杂的基于XUL的插件,我需要使用Add-on SDK中的一些函数。 Is this possible? 这可能吗? If so, does anyone have working sample code, preferably using the page-worker module? 如果是这样,有没有人有工作示例代码,最好使用页面工作者模块?

The following is the way devtools does it, but certain modules will choke (the obvious candidate being self ). 以下是devtools的方式,但某些模块会窒息(明显的候选人是self )。 I think you will have better luck with low-level modules. 我认为你会有更好的运气与低级模块。

let {Loader} = Cu.import("resource://gre/modules/commonjs/toolkit/loader.js", {});
let loader = new Loader.Loader({
  paths: {
    "": "resource://gre/modules/commonjs/"
  },
  globals: {},
});

let require = Loader.Require(loader, { id: "myaddon" })
// now you can require addon-sdk modules

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

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