一个小解决方法是在添加新搜索引擎后直接更改默认搜索引擎的首选项:
browser.search.defaultenginename
此首选项采用搜索引擎的确切名称。
此外,在这个 MDN 教程中有更多关于添加搜索引擎的信息:
function startup(data, reason) {
firstRun = reason == ADDON_INSTALL;
// Re-select the search engine if this is the first run
// or we're being re-enabled.
selectSearch = firstRun || reason == ADDON_ENABLE;
// Only add the engine if it doesn't already exist.
if (!Services.search.getEngineByName(ENGINE_DETAILS.name)) {
Services.search.addEngineWithDetails.apply(Services.search,
["name", "iconURL", "alias", "description", "method", "url"].map(
function (k) ENGINE_DETAILS[k]))
}
let engine = Services.search.getEngineByName(ENGINE_DETAILS.name);
// If the engine is not hidden and this is the first run, move
// it to the first position in the engine list and select it
if (selectSearch && !engine.hidden) {
Services.search.moveEngine(engine, 0);
Services.search.currentEngine = engine;
}
}