TeNNoX
TeNNoX

Reputation: 2075

Firefox addon access config

I want to write a simple Firefox addon for protecting my search engine, cause on every restart of firefox the searchengine and also keyword.URL is set to u-search.

I tried the addon BrowserProtect but it doesn't protect keyword.URL! So I started by creating an addon on builder.addons.mozilla.org cause it seemed easy to use.

My code looks like this (added together from code snippets):

var Widget = require("widget").Widget;
var tabs = require('tabs');

exports.main = function() {

    new Widget({
        id: "searchengineprotect",
        label: "SearchEngineProtect",
        contentURL: "http://www.mozilla.org/favicon.ico",

        onClick: function(event) {
            var {Cc, Ci} = require("chrome");
            var prefs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsIPrefBranch);
            prefs.setCharPref("keyworld.URL", "http://google.de/search?q=");
        }
    });
};

I just changed the code in the "onClick" function.

But when I click on the little button in firefox the console reports this error:

Fehler: searchengineprotect: An exception occurred.
NS_ERROR_XPC_GS_RETURNED_FAILURE: Component returned failure code: 0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE) [nsIJSCID.getService]
undefined 35
Traceback (most recent call last):
  File "resource://jid0-zg1n2skgq7y6lrq6hbl96hno8ke-at-jetpack/searchengineprotect/lib/main.js", line 35, in exports.main/<.onClick
    var prefs = Cc["@mozilla.org/cookieService;1"].getService(Ci.nsIPrefBranch);
  File "resource://jid0-zg1n2skgq7y6lrq6hbl96hno8ke-at-jetpack/addon-sdk/lib/sdk/deprecated/events.js", line 153, in _emitOnObject
    listener.apply(targetObj, params);
  File "resource://jid0-zg1n2skgq7y6lrq6hbl96hno8ke-at-jetpack/addon-sdk/lib/sdk/deprecated/events.js", line 123, in _emit
    return this._emitOnObject.apply(this, args);
  File "resource://jid0-zg1n2skgq7y6lrq6hbl96hno8ke-at-jetpack/addon-sdk/lib/sdk/widget.js", line 282, in _onEvent
    this._emit(type, eventData);
  File "resource://jid0-zg1n2skgq7y6lrq6hbl96hno8ke-at-jetpack/addon-sdk/lib/sdk/widget.js", line 431, in WidgetView__onEvent
    this._baseWidget._onEvent(type, this._public);
  File "resource://jid0-zg1n2skgq7y6lrq6hbl96hno8ke-at-jetpack/addon-sdk/lib/sdk/widget.js", line 850, in WC_addEventHandlers/listener/<
    self._widget._onEvent(EVENTS[e.type], null, self.node);
  File "resource://jid0-zg1n2skgq7y6lrq6hbl96hno8ke-at-jetpack/addon-sdk/lib/sdk/timers.js", line 31, in notify
    callback.apply(null, args);

So If you know how I could fix that error or even how I could stop firefox from changing the search engine... Would be awesome! :)

Upvotes: 0

Views: 256

Answers (1)

Following the comment - it's a misspelling issue.
Use keyword.URL instead of keyworld.URL (without the "L")

Upvotes: 1

Related Questions