you can find some information about Places (the bookmarks and history system) in Mozilla Developer Center: https://developer.mozilla.org/en/Places
you can find examples in our tests unit (notice some of them could not be optimized for performance)
h t t p://mxr.mozilla.org/mozilla-central/search?string=nsINavHistoryobserver&find=tests
What you need is to get history service, and attach an history observer to it
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
var historyObserver = {
onBeginUpdateBatch: function() {},
onEndUpdateBatch: function() {},
onVisit: function(aURI, aVisitID, aTime, aSessionID, aReferringID, aTransitionType) {},
onTitleChanged: function(aURI, aPageTitle) {},
onBeforeDeleteURI: function(aURI) {},
onDeleteURI: function(aURI) {},
onClearHistory: function() {},
onPageChanged: function(aURI, aWhat, aValue) {},
onDeleteVisits: function() {},
QueryInterface: XPCOMUtils.generateQI([Ci.nsINavHistoryObserver])
};
hs.addObserver(historyObserver, false);
You should try to reduce most as possible the work you do in the addVisit notification, you should really handle it asynchronously to avoid slowing down the basic browser functionality.