Find the default search engine used by the user in firefox search bar
I need to provide a search box in my firefox addon, but I want to find o开发者_如何学Gout the user's preferred search engine so that I can make that as a default when the user installs my addon.
Now, I want to find out what the user chose as a preffered search engine in his firefox search bar. Anyone knows how can I achieve this?
Thanks Kapil
This will get you currently selected search engine:
var ss = Components.classes["@mozilla.org/browser/search-service;1"].
getService(Components.interfaces.nsIBrowserSearchService);
var engine = ss.currentEngine;
or get it by name:
var engine = ss.getEngineByName(engineName);
Look up more details here.
精彩评论