Reputation: 763
I am working on a Chrome extension, and I want to want to extend (but not override) the browser's search (ctrl-F or cmd-F) feature.
Is there any way to make my extension receive a message when the browser's search feature gets invoked, along with the search term entered.
(Is the search box UI in HTML? If so, is there a way to access it, so that I could bind to the keypress/keydown event on it search input element?)
Upvotes: 4
Views: 3122
Reputation: 18534
Till date there is no way you can access Standard Chrome Find Dialog or receive a message when the browser's search feature gets invoked or rendering search box UI in HTML?
( Which is triggered through Ctrl + F or Cmd + F).
However, you can use window.find()1.
This Work Around will Override because extension is not possible till date.
Define your own Command using chrome.commands API
"commands":{
"sample":{
"suggested_key" : {
"default":"Ctrl+F",
"windows":"Ctrl+F"
},
"description":"Thisismycustomkeyforchromeextension"
},
}
and add a listener for your command Ctrl + F or Cmd + F
chrome.commands.onCommand.addListener(function (command) {
//Do what ever you want here
})
This will override Standard Ctrl + F or Cmd + F and use your own content script to frame all the UI and functional Logic for scraping the Page for related Content.
1: window.find()
scope falls in selected text only
Upvotes: 2