4

I am building a simple Firefox extension using the Add-on SDK 1.0.

Scouring the docs and googling a lot, I couldn't find a way to create a simple menu under the browser's tools menu. Add-on SDK has a context-menu module, which (obviously) only handles the page context menus, which is not what I'm after. Is it that Add-on SDK does not have a module for this yet? If so, I believe I have access to all the firefox's XPCOM API in the Add-on SDK extension, but I can't figure out how to use this and create a simple menu entry under the tools menu.

Any pointers on how I might do this?

(BTW, not sure about the tags of this question, please correct if you feel so)

Wladimir Palant
  • 56,865
  • 12
  • 98
  • 126
sharat87
  • 7,330
  • 12
  • 55
  • 80
  • I don't think that Jetpack has this functionality, it allows only limited interaction with existing UI. – Wladimir Palant Aug 22 '11 at 13:48
  • Can't I even access the browser's document object, probably I can modify it if I could get access to it. It would be a pain to turn this extension into a non-jetpack on now :/ – sharat87 Aug 22 '11 at 13:52
  • I think that Jetpack extensions run in a separate process which rules out accessing DOM (if they don't then it is planned for the near future). – Wladimir Palant Aug 22 '11 at 14:41
  • Jetpack's addon-kit api doesn't allow you to interact with the browser DOM & menus currently, except as you say for context menus, however it is totally valid to require chrome and then any of Firefox's lower level apis to insert Xul nodes via JS code. – therealjeffg Aug 22 '11 at 17:05
  • @canuckistani, "to require chrome", do you mean there is a jetpack sdk module called `chrome` to access "any of Firefox's lower level apis"? I couldn't find any documentation on this (I couldn't find it even inside the addon sdk). Could you give some pointers on this (as an answer ofcourse). – sharat87 Aug 23 '11 at 04:53
  • Sure, here is a simple SDK example that uses lower-level apis: https://builder.addons.mozilla.org/addon/1013359/latest/ It doesn't really answer your question, but once you are using xpcom services you should be able to do what you want. Best approach is of course to make a separate module for the chrome-level code and write tests for it, of course ;) – therealjeffg Aug 24 '11 at 21:00

1 Answers1

2

I wrote a module called menuitems which can be used to easily add a single menuitem to any of the normal menu bar items. It's on github here.

I haven't had the time to write docs yet, but you can find an example here, and the example is on AMO here.

I'll blog about it one of these days..

erikvold
  • 15,988
  • 11
  • 54
  • 98
  • 1
    Awesome stuff there! I tried the package in my project, but the `require("unload+")` throws a `ModuleNotFoundError`. I see that there are two dependencies listed in the package.json file, *api-utils* and *vold-utils*. Where can I get these? ...sorry if this should be obvious, am only starting off with jetpack :). Thanks for the answer. – sharat87 Aug 26 '11 at 09:07
  • I should make it more clear where vold-utils can be found, but it's here https://github.com/erikvold/vold-utils-jplib and api-utils in built in to the Addon SDK – erikvold Aug 26 '11 at 21:54