mirror of
https://github.com/GoogleChrome/chrome-extensions-samples.git
synced 2026-03-27 13:29:34 +07:00
1.7 KiB
1.7 KiB
Open Extension API Reference
This example demonstrates how to use the Omnibox API to quickly navigate to Chrome extension API reference pages directly from the address bar.
Overview
The extension registers the keyword "api" in Chrome's omnibox. When users type "api" followed by a space, they can search for any Chrome extension API and navigate directly to its documentation page.
Implementation Notes
The extension uses several Chrome APIs:
chrome.omnibox- Registers the "api" keyword and handles input/selection eventschrome.storage.local- Stores recent search history to provide personalized suggestionschrome.alarms- Used for periodic tip fetching from an external service- Content script - Runs on the API reference pages
When the user types in the omnibox:
onInputChangedprovides API suggestions based on user input and search historyonInputEnteredopens the selected API's reference page in a new tab- The most recent searches (up to 4) are saved for future suggestions
The service worker is organized into modules:
sw-omnibox.js- Handles omnibox events and navigationsw-suggestions.js- Generates API suggestionssw-tips.js- Fetches extension development tips
Running this extension
- Clone this repository.
- Load this directory in Chrome as an unpacked extension.
- Type "api" in the address bar and press Space or Tab.
- Start typing an API name (e.g., "tabs", "storage", "scripting").
- Select a suggestion or press Enter to open the API reference page.