The experimental showforpage
API allows for acting on page load related events.
var showForPage = require('showforpage').ShowForPage,
listeners;
exports.main = function () {
listeners = showForPage({
onLocationChange : checkUrl,
onPageShow : checkForStuffInHTML
});
};
exports.onUnload = function (reason) {
if (reason !== 'shutdown') {
listeners.remove();
}
};
- onLocationChange - a callback that's called when the URL is changed. (optional)
- onPageShow - a callback that's called when the page has loaded. (optional)
- onLink - a callback that's called when a new link element has been added to the page. (optional)
Should be a function. Is called with the URL of the current page as a single argument and has the document of the page that is checked as its context.
Same as onLocationChange
but also includes an additional second parameter that is true
if the background page is loaded in background and otherwise false. That second parameter is useful as it indicates that onLocationChange
likely hasn't been called prior to onPageShow
.
Should be a function. Is called with the URL of the current page as its first argument, an object containing all link data as its second argument (rels, href and title) and includes a last parameter like onPageShow
that indicates if the page is loaded in the background. The function is called with the link element as its context.
Follow the Add-on SDK's documentation for third party packages.
- Flattr Firefox Add-on: Source
- Support for Firefox 29 by no longer using the tab-browser SDK module
- Support for Mozilla's Add-on SDK version 1.13b1
- New
onLink
listener that listens for new link elements that are added to the page - No longer triggers
onPageShow
events on hash changes and tab selects - useonLocationChange
change for that onLocationChange
is now called in the context of the page document and is given a second parameter indicating whether the document has been loaded- Triggers
onLocationChange
on active tabs on initialization
- Moved the
onLocationChange
andonPageShow
listeners, that were called when a new page was loaded, in the UrlbarButton module into this new module and then also removed the callbacks that were included as an argument when those listeners were called.