Omnibox multipe Keyword
开发者_如何学JAVAMy question is about the Omnibox. The think provided by the Chrome API, i wanted to know if there is a possibility to have a multiple keyword on the manifest.
I've thinking about a regex or something like that but i don't really know what to do...
I think i've just find a solution.
I've discover that when you make a search for 'TRY' by using google the url is :
http://www.google.com/#sclient=psy&hl=fr&site=&source=hp&q=TRY&aq=f&aqi=&aql=&oq=&pbx=1&fp=ec3d6f66084ab746
And when it come from Chrome URL it's :
http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=TRY
So basically if i check if there is sourceid=Chrome on the url i can redirect like this. What do you think ?
// If Google Search from the URL (sourceid)
if(URL.match('google') && parseUri(URL).queryKey['sourceid'] == 'chrome')
{
chrome.tabs.update(tabId, { url: 'http://search.yahoo.com/search?p=' + parseUri(URL).queryKey['q'] });
return;
} // If Bing Search from the URL (setmkt)
else if(URL.match('bing') && parseUri(URL).queryKey['setmkt'])
{
chrome.tabs.update(tabId, { url: 'http://search.yahoo.com/search?p=' + parseUri(URL).queryKey['p'] });
return;
}
Sorry, not possible.
I see you are still trying to make custom search provider. I wanted to give you an idea of what I did in a similar extension which triggers google lucky search instead of regular one if you type your keyword in capital letters for example. It has some pitfalls and limitations (the biggest one is that default search provider must be google and it still briefly shows google search results), but at least something:
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
if(changeInfo.status == "loading") {
var url = $.url.setUrl(tab.url);
if((url.attr("protocol") == "https" && url.attr("host").indexOf("encrypted.google.") == 0
|| url.attr("protocol") == "http" && url.attr("host").indexOf("www.google.") == 0)
&& url.attr("path") == "/search" && url.param("q") && isAllCapital(url.param("q"))) {
//do something with search term inside url.param("q")
}
}
});
(I am using URL Parser plugin).
精彩评论