firefox-addonfirefox-addon-sdkbrowser-history

accessing history in a firefox addon


I'm working on a firefox addon, using the addon builder. I want to periodically scan the browser's history.. the entire history. I'm looking for functionality like chrome's history api. It seems window.history is limited to session history only. Any help? I'm going crazy trying to figure this out. Addons like history export must do something like this, but their code is not immediately understandable to me.


Solution

  • You'll need to access the xpcom service nsIBrowserHistory, here's some example code that works with the SDK:

    https://builder.addons.mozilla.org/package/157396/latest/

    The places API is a bit verbose, there are extensive examples available on MDN:

    Querying Places

    There is also a module developed by Mozilla community members available here that provides some abstractions:

    Jetpack-Modules/places.js at Github

    Note: I'm not sure if theabove module has been tested against recent versions of Firefox and the SDK.