Last active
March 7, 2016 03:29
-
-
Save greenido/5134928 to your computer and use it in GitHub Desktop.
background.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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