Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using user preferences in Firefox addon

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.

like image 410
user1882981 Avatar asked Oct 06 '22 17:10

user1882981


1 Answers

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

like image 167
user1882981 Avatar answered Oct 11 '22 17:10

user1882981