从传统的基于XUL的附加组件中访问附加SDK? [英] Access the Add-on SDK from within a traditional XUL-based add-on?

查看:155
本文介绍了从传统的基于XUL的附加组件中访问附加SDK?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个庞大而复杂的基于XUL的插件,我需要使用附加SDK中的一些函数。这可能吗?如果是这样,有没有人有工作示例代码,最好使用页面工作模块?

I have a large and complex XUL-based addon for which I need to use a few functions from the Add-on SDK. Is this possible? If so, does anyone have working sample code, preferably using the page-worker module?

推荐答案

以下是devtools它,但某些模块会呛(显然候选人 self )。我认为你将会对低级模块有更好的运气。
$ b

The following is the way devtools does it, but certain modules will choke (the obvious candidate being 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

这篇关于从传统的基于XUL的附加组件中访问附加SDK?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆