Reputation: 133
I am trying to build firefox extension which executes script in the tab. It can be easily done in chrome but I didn't find any api to do that in firefox.
Can you guys show me the way ?
My chrome extension code is here on github
Upvotes: 1
Views: 3071
Reputation: 839
Try following code for add-ons created from scratch:
var numTabs = gBrowser.tabContainer.childNodes.length;
for (var i = 0; i < numTabs; i++) {
var currentTab = gBrowser.tabContainer.childNodes[i];
var currentBrowser = gBrowser.getBrowserForTab(currentTab);
var doc=currentBrowser.contentDocument;
// Use gBrowser.selectedTab or doc.defaultView.location to filter
// doc refers DOM for tab
}
Refer following url for more details:
https://developer.mozilla.org/en-US/docs/Code_snippets/Tabbed_browser
Upvotes: 1
Reputation: 6184
Straight off the SDK home page is a link for "listing open pages."
https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/tutorials/list-open-tabs.html
Using the SDK is seriously much easier than trying to learn the ins and outs of the old API.
Upvotes: 4