Does anyone know of an example/sample .xpi file that uses Components.utils.import开发者_如何学JAVA to load a custom code module? I cannot get it to work. Basically I cannot get it to work when I package to a .jar file. Is this a limitation to use code modules?
A sample would be really helpful, probably with the code below.
var EXPORTED_SYMBOLS = ["foo", "bar"];
function foo() {
return "foo";
}
var bar = {
name : "bar",
size : 3
};
Has passed some time, but here you have:
// modules/module.jsm file
var EXPORTED_SYMBOLS = ["myUniqueCode"];
// wrap your code
var myUniqueCode = {
foo : function() {
return "foo";
},
bar : {
name : "bar",
size : 3
}
}
// load module where you need it
Components.utils.import("resource://your_addon_name/module.jsm");
// use myUniqueCode.foo()
As @felix-kling recommends:
// add to your chrome.manifest file
resource your_addon_name modules/
精彩评论