MDN wants to learn about developers like you: https://qsurvey.mozilla.com/s3/MDN-dev-survey-2018-1

この翻訳は不完全です。英語から この記事を翻訳 してください。

拡張機能に、ユーザーがアドレスバーに入力した時のカスタマイズされた振る舞いを有効にします。

When the user focuses the browser's address bar and starts typing, the browser displays a drop-down list containing suggested pages, based on what they typed. This gives the user a quick way to access, for example, pages from their history or bookmarks.

The omnibox API provides the extension a way to customise the suggestions displayed in the drop-down, when the user enters a keyword defined by the extension. It works as follows:

  1. First, the extension must include an "omnibox" key in its manifest.json file, which defines a keyword.
  2. When the user focuses the address bar and types the keyword, followed by a space, the extension will get an omnibox.onInputStarted event.
  3. Optionally, the extension can call omnibox.setDefaultSuggestion() to define the first suggestion that will be displayed in the address bar drop-down.
  4. As the user continues to type characters after this, the extension will get omnibox.onInputChanged events. The event listener will be passed the current value the user has typed, and will be able to populate the address bar drop-down with suggestions. If the extension set a default suggestion using omnibox.setDefaultSuggestion(), then this will appear first in the drop-down.
  5. If the user accepts a suggestion, the extension will get an omnibox.onInputEntered event. The event listener will be passed the accepted suggestion.
  6. If the user dismisses the drop-down, the extension will get an omnibox.onInputCancelled event.

omnibox.OnInputEnteredDisposition
Describes the recommended method to handle the selected suggestion: open in the current tab, open in a new foreground tab, or open in a new background tab.
omnibox.SuggestResult
Object representing a suggestion to add to the address bar drop-down.

関数

omnibox.setDefaultSuggestion()
Defines the first suggestion that appears in the drop-down when the user enters the keyword for your extension, followed by a space.

イベント

omnibox.onInputStarted
Fired when a the user focuses the address bar and types your extension's omnibox keyword, followed by a space.
omnibox.onInputChanged
Fired whenever the user's input changes, after they have focused the address bar and typed your extension's omnibox keyword, followed by a space.
omnibox.onInputEntered
Fired when the user accepts one of your extension's suggestions.
omnibox.onInputCancelled
Fired when the user dismisses the address bar drop-down, after they have focused the address bar and typed your extension's omnibox keyword.

ブラウザ実装状況

ChromeEdgeFirefoxFirefox for AndroidOpera
OnInputEnteredDisposition 有り 無し52 無し 有り
SuggestResult 有り 無し52 * 無し 有り
onInputCancelled 有り 無し52 無し 有り
onInputChanged 有り 無し52 無し 有り
onInputEntered 有り 無し52 無し 有り
onInputStarted 有り 無し52 無し 有り
setDefaultSuggestion 有り 無し52 * 無し 有り

Example extensions

Acknowledgements

This API is based on Chromium's chrome.omnibox API.

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

ドキュメントのタグと貢献者

 このページの貢献者: Uemmra3
 最終更新者: Uemmra3,