Wednesday, May 9, 2012 5:14:02 AM
Barring a few annoying bugs, Opera 12.00's new Windows and Tabs API is a vast improvement over the old one. At first glance however, it seems to be missing features like the ability to move tabs. Fortunately, that functionality is available, it just isn't obviously accessible, which is why I wrote a library of extensions to the API.
Windows and Tabs API Extensions adds the following:
- Fixes a bug with BrowserTabGroupManager.create which destabilizes Opera (build 1387) if grouped tab is already part of a group. (The fix merely ungroups each tab before creating the new group)
- Defines a global TabUtils object with useful helper methods
- Adds nextSibling and previousSibling properties to BrowserTab and BrowserTabGroup objects. These let you get the adjacent tabs/groups in a tab or group's container.
- Adds nextTab and previousTab properties to BrowserTab objects. These let you get the tabs immediately to the left and right of a given tab.
- Adds firstTab and lastTab properties to BrowserTabGroup objects. These let you get the leftmost and rightmost tabs in a group.
- Adds an ungroup() method to BrowserTab objects, which (if possible) removes the tab from its group.
- Adds an at() method to BrowserTabGroup and BrowserWindow objects, which finds the tab or group at a given position.
- Adds an insertAfter() method to BrowserTabGroup and BrowserWindow objects, which acts just like insert(), but adds the item after the child item instead of before it.
- Adds a move() method to BrowserTabGroup and BrowserWindow objects, which moves a tab or group to a given position within the group or window.
You can find the library and more information about it on its Github page
Sunday, April 22, 2012 7:05:47 AM
There was an Opera 12.00 snapshot a while back with an updated tabs and windows API. Unfortunately, half of it was broken. Now, in the latest snapshot, it's not!
There isn't any documentation available to my knowledge
, but here are a few of the things I've figured out.
- Tabs now have unique IDs, which will make identifying them much easier.
- Tab groups are now visible to extensions! If you have a reference to a tab, you can also get a reference to the tab group it is in (if any).
- Opera internal pages are now exposed to extensions. In other words, opera.extension.tabs.getFocused() actually returns something when you have speed dial focused!
- You can now get a lot more info about a tab. For instance, you can tell whether it is closed, locked, focused, private, and which position it is in the tab bar.
- Tabs now have a "readyState" property. I can't find any reference to a "readystatechanged" event, but at least we can now tell when a tab is finished loading.
- You can focus tabs/groups!
There's probably a lot more, but without documentation of any kind, I'm just trying things to see what works at the moment.
Here are a few of the fun things I'll be able to add to Tab Vault now:
- Save tab groups
- Open a group of saved tabs as a tab group
- I can now tell the difference between a tab that hasn't loaded and one that has loaded but doesn't have a favicon. As a result, the importer won't have to wait ~15 seconds for every tab without a favicon.
Documentation on the new API is now available at http://dev.opera.com/articles/view/extensions-api-windows-tabs/
. Also, check my comment at the bottom of that page, as there are still a couple bugs to watch out for (which are currently halting my progress on Opera 12.00-ifying Tab Vault).