I need to write down an extension to do the following:
- Whenever i use a keyword, it searches on my personal database (working)
- If i type something in the OmniBox and press my button created from a BrowserAction, i want to go to the same place.
My problem so far is to get the content of the omni box into a variable so i can attach to the end of my url and perform the search.
Anybody can help? Here is what i made so far:
manifest.json
"name": "My Search",
"version": "1.0",
"description": "My Search",
"manifest_version": 2,
"omnibox": {
"keyword": "MyKeyword"
},
"browser_action": {
"default_icon": "icon.png"
},
"background": {
"scripts": ["background.js"]
},
"permissions": [
"tabs"
]
background.js
chrome.omnibox.onInputEntered.addListener(function(text) {
chrome.tabs.create({'url': "http://mywebsite/search/" + text});
});
chrome.browserAction.onClicked.addListener(function(tab) {
var action_url = "http://mywebsite/search/";
var omni = "";
chrome.tabs.update(tab.id, {url: action_url + omni});
});
chrome.browserAction.setBadgeText({text: "MyBadge"})
So, i just need to sabe the current value of the omni bar into the variable "omni". But how?
I appreciate any help.