browser.omnibox.setDefaultSuggestion({
description: `Search the Firefox codebase
(e.g. "hello world" | "path:omnibox.js onInputChanged")`,
});Address bar suggestions / notebook
Address bar suggestions
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
browser.omnibox.onInputChanged.addListener((text, addSuggestions) => {
let headers = new Headers({ Accept: "application/json" });
let init = { method: "GET", headers };
let url = buildSearchURL(text);
let request = new Request(url, init);
fetch(request).then(createSuggestionsFromResponse).then(addSuggestions);
});browser.omnibox.onInputEntered.addListener((text, disposition) => {
let url = text;
if (!text.startsWith(SOURCE_URL)) {
// Update the URL if the user clicks on the default suggestion.
url = `${SEARCH_URL}?q=${text}`;
}
switch (disposition) {
case "currentTab":
browser.tabs.update({ url });
break;
case "newForegroundTab":
browser.tabs.create({ url });
break;
case "newBackgroundTab":
browser.tabs.create({ url, active: false });
break;
}
});