I have an add-on wip called Fantastic Bar which does what you want.
Taking control over urlbar in Firefox
-
17-07-2023 - |
Pregunta
I would like to modify the urlbar to include additional functionalities. Something like instantfox does.
For this I need 2 things:
- I need to listen to keypress events from my extension.
- I want to disable the default suggestions popup.
What would be the cleanest way to accomplish this? If possible using the addon sdk.
Solución
Otros consejos
This is probably the messy way you mention in your comment, but I think it's the best way to do it with the SDK
const doc = require('sdk/window/utils').getMostRecentBrowserWindow().document;
var urlBarIcons = doc.getElementById('urlbar-icons')
var btn = doc.createElement('toolbarbutton');
btn.setAttribute('id', 'foo');
btn.setAttribute('image', loc('bar.png'));
btn.addEventListener('command', function(event) {
urlBtnClick();
}, false);
urlBarIcons.appendChild(btn);
Take a look at the examples from addon-sdk wiki, in particular the awesomebar module, how to use it. That's the easiest way to give custom suggestions on the urlbar.
I know it does not disables it (item 2 from your question) but you'll have control on what to suggest and maybe that way you don't need to to listen to keypress events (item 1 from your question).
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow