0
我想編寫一個簡單的Firefox插件來保護我的搜索引擎,導致每次重新啓動firefox時都會搜索到searchengine,並且還會將keyword.URL設置爲u-search。Firefox插件訪問配置
我試過插件BrowserProtect,但它不能保護keyword.URL! 所以我開始在builder.addons.mozilla.org上創建一個插件,因爲它很容易使用。
我的代碼看起來像這樣(從代碼片段加在一起):
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=");
}
});
};
我只是改變了代碼的「點擊」功能。
但是,當我在Firefox中點擊小按鈕控制檯報告這個錯誤:如果你知道我怎麼能解決這個錯誤甚至如何我可以從改變搜索引擎停止火狐
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);
左右。 ..會很棒! :)
只是一個想法 - 「keyword.URL」而不是「keyworld.URL」。它可以這麼簡單嗎? – 2013-09-02 07:51:22