Developers › Add-ons blog

We've got some new extension APIs for you

October 2, 2012 · by Shwetank Dixit

We've just released Opera 12.1 beta, which is better, faster, and more secure than ever. However, apart from all that goodness, we've got some new goodies for all you extension developers too. Opera 12.1 beta features some additional APIs that you can use to make new extensions with, or add power to your existing ones. Lets take a a brief look at them.

Context Menu API

For a long while, you've asked us to have a way to integrate extensions in the conext menu (the menu you get when you right-click on an element in a web page). With the Context Menu API, you can do exactly that. You have the ability to create sub-menus if you want. You can also specify when exactly should the menu item be visible (when you right-click on an image, a link, a form element, the page in general or all of the above). Head over to the documentation to read on how to use the API. In the meantime, try some extension which already utilize this API, like the 'Tineye Context Search' and the 'Goto IMDB 2' extensions.

Screenshot API

The name is pretty self-explanatory. You can now use the opera.extension.getScreenshot() function to capture the screenshot of the visible portion of the page, without any other part of the browser like the toolbars etc. You can call it either from the background script or the injected script. Take a look at the 'Screenshoter' extension which already uses it! You can read the documentation to find out more about it.

Resouce Loader API

Till now, you could not load resources from other parts of the extension. The Resource Loader API makes it possible for you to do that in a very simple manner. All you need to do is call opera.extension.getFile() to access the file and use the W3C File API to actually read the file. This makes it easy to access some other parts of the extension which might prove handy, like accessing the extension's logo or the config.xml file. Opera user BS-Harou also created a very cool 'Require.JS' function for injected scripts using this API, which you should check out. As always, more info on how to use it is there on the documentation page.

We hope you'll like the new APIs for extensions in Opera 12.1, and we look forward to what you can create with them!

Readers' comments 3

Left under the original article, as archived.

  • Mağruf ÇolakoğluWednesday, October 10, 2012 7:49:23 PM

    Thanks for explanation.
  • HenryFriday, October 12, 2012 1:18:41 AM

    yes
  • Manuel Andreas KuhnTuesday, October 16, 2012 9:42:34 PM

    Thanks, but can you please adjust the window/tabs api to give the injected script access to the tabid, or onmessage as source the tab that send the message. really need this.

About this article

Published inAdd-ons blog
DateOctober 2, 2012
AuthorShwetank Dixit
Tagsscreenshot, context menu, apis, resource loader, 12.1, screenshots
OriginalInternet Archive