5

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.

Filipe Silva
  • 21,189
  • 5
  • 53
  • 68
user1882981
  • 188
  • 1
  • 2
  • 15

1 Answers1

4

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 :)

user1882981
  • 188
  • 1
  • 2
  • 15