Reputation: 3878
One of the neat things about Chrome is that, if you type a word on the address bar, it suggests what relevant URLs might be. For example if I type "New York", it suggests nytimes.com
Can an extension be developed that provides customized suggestions? For instance, if I have an internal company website, say foo which hosts documents with numeric IDs - say http://domain.com/123 or http://domain.com/234. When someone types "123" on the browser address bar, I want http://domain.com/123 to show as a suggestion (even if it has never been accessed before).
Is something like this possible? If so, I would love some pointers (I've never developed a Chrome extension, but if possible, I can look things up and get this implemented).
Thanks! Raj
Upvotes: 0
Views: 513
Reputation: 18534
Yes, it is possible through Omnibox, https://developer.chrome.com/extensions/omnibox.html I have written a sample implementation here :
Manifest File:
{
"name": "Omnibox Demo",
"description" : "This is used for demonstrating Omnibox",
"version": "1",
"background": {
"scripts": ["background.js"]
},
"omnibox": {
"keyword" : "demo"
},
"manifest_version": 2
}
JS File:
chrome.omnibox.setDefaultSuggestion({"description":"Search %s in Dev Source Code"});
chrome.omnibox.onInputStarted.addListener(function() {
console.log("Input Started");
});
chrome.omnibox.onInputCancelled.addListener(function() {
console.log("Input Cancelled");
});
chrome.omnibox.onInputEntered.addListener(function (text) {
console.log("Input Entered is " + text);
});
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"}
]);
});
Upvotes: 2