Skip to content

Instantly share code, notes, and snippets.

@dergachev
Created May 17, 2013 23:14
Show Gist options
  • Save dergachev/5602555 to your computer and use it in GitHub Desktop.
Save dergachev/5602555 to your computer and use it in GitHub Desktop.
omnibox-chrome-extension-demo with bookmarklet support; see https://github.com/dergachev/chrome-bookmark-search/issues/1
// This event is fired each time the user updates the text in the omnibox,
// as long as the extension's keyword mode is still active.
chrome.omnibox.onInputChanged.addListener(
function(text, suggest) {
console.log('inputChanged: ' + text);
suggest([
{content: text + " one", description: "the first one"},
{content: text + " number two", description: "the second entry"}
]);
});
// This event is fired with the user accepts the input in the omnibox.
chrome.omnibox.onInputEntered.addListener(
function(text) {
console.log('inputEntered: ' + text);
alert('You just typed 2 "' + text + '"');
chrome.tabs.executeScript(null, {code:"document.body.innerHTML = 'bobbbb';"});
});
{
"name": "Omnibox Example",
"description" : "To use, type 'omnix' plus a search term into the Omnibox.",
"version": "1.1",
"background": {
"scripts": ["background.js"],
"persistent": false
},
"omnibox": { "keyword" : "b" },
"permissions": [
"activeTab"
],
"manifest_version": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment