I'm building a Firefox Extension. It's injecting CSS into one website. But I want to inject it accordingly to user preferences. This is the most important part in my add-on:

exports.main = function() {

var pageMod = require("page-mod");

var test = require("preferences-service");

pageMod.PageMod({
  include: "http://example.org/*",
  contentStyle: "something here"
  });
};

But there's an error in Mozilla Firefox Error Console:

Error: Module: undefined located at undefined has no authority to load: preferences-service

And I don't know what I should do to make it work. Has anybody any ideas? :) Maybe there's other way?

Actually, I want to read preferences, and then generate adequate styles. I've got user preferences in defaults/preferences/prefs.js, if this is useful information.

有帮助吗?

解决方案

Okay, now it works. If you've got the same or similar problem, edit harness-options.json file. After

"page-mod": {
"path": "addon-kit/lib/page-mod.js"
},

add:

"preferences-service": {
"path": "api-utils/lib/preferences-service.js"
}, /*with or without the comma, as the case may */

That's all :)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top