2

Firefox 24 で壊れた Firefox アドオンを開発しました。

私のアドオンは、いくつかのユーザー設定に基づいて、検索エンジンを検索バーに追加します。検索エンジンを追加するには、 のaddEngine()を使用しnsIBrowserSearchServiceます。

Firefox 23 までは、この機能は追加されたエンジンも選択していたため、ユーザーはすぐに使用できました。Firefox 24 から、この動作は停止しました: エンジンは追加されていますが、もう選択されていません。

ただし、ドキュメントにはまだ記載されています

...新しいエンジンはすぐに自動的に使用されます。

新しいエンジンを Firefox 24 でもすぐに使用するにはどうすればよいですか?

4

1 に答える 1

2

少しの回避策は、新しい検索エンジンを追加した後で、デフォルトの検索エンジンの設定を直接変更することです。

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;
    }
}
于 2013-10-04T01:02:16.210 に答える