Skip to content

Instantly share code, notes, and snippets.

@greenido
Last active March 7, 2016 03:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save greenido/5134928 to your computer and use it in GitHub Desktop.
Save greenido/5134928 to your computer and use it in GitHub Desktop.
background.js
// each time the user updates the text in the omnibox this event
// is fired and we will use it to suggest search terms for
// our internal users.
chrome.omnibox.onInputChanged.addListener(
function(text, suggest) {
suggest([
{content: "CRM" , description: " fetch the internal CRM"},
{content: "ERP" , description: " fetch the internal ERP"},
{content: "sales", description: " fetch the lastest sales report"}
]);
});
// This event is fired with the user accepts the input in the omnibox.
chrome.omnibox.onInputEntered.addListener(
function(text) {
if (text.indexOf("/") < 1) {
text += "/";
}
if (text.indexOf("http") < 0) {
text = "http://our-internal-portal/" + text;
}
alert('We are taking you to: "' + text + '"');
navigate(text);
});
function navigate(url) {
chrome.tabs.getSelected(null, function(tab) {
chrome.tabs.update(tab.id, {url: url});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment