开发者

Google Chrome extension to read omnibox imput and make a XMLHttpRequest based on it

Say a user types in "testing" in the omnibox. I need an extension to make a page request to 开发者_开发问答http://mywebsite.com?url=testing. I can't use the keyword recognition thing, because this must work for ANY word. Any idea where to start?


There is currently no way to listen on omnibox key inputs unless you register a keyword, explained here http://code.google.com/chrome/extensions/omnibox.html

An alternative way, would be to use the experimental WebRequest API, you can listen before every request made and do some logic that you require per URL.

For example, firing an XHR request on every request:

chrome.experimental.webRequest.onBeforeRequest.addListener(function(details) {
   var xhr = new XMLHttpRequest();
   xhr.open('GET', 'http://mywebsite/audit?url=' + details.url, true);
   xhr.send();
});

Note that this is experimental, therefore the API is not stable yet and may change in the future.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜