Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'd like to to know which interface can be used to get the visit count of each link in firefox's bookmarks and history for developing an extension

I've tried using nav-history-service to get the links for bookmarks and history but can't figure out how to view the visit count.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
428 views
Welcome To Ask or Share your Answers For Others

1 Answer

This code here will go through the first 10 bookmark entires. If it's a url it checks its .accessCount property which holds the number of times it was visited.

var hs = Cc["@mozilla.org/browser/nav-history-service;1"].getService(Ci.nsINavHistoryService);

var query = hs.getNewQuery();
var options = hs.getNewQueryOptions();

// Query users bookmarks, not history
options.queryType = options.QUERY_TYPE_BOOKMARKS;
// Execute the search and store results
var result = hs.executeQuery(query, options);

// Open the root containerNode and open it
var resultContainerNode = result.root;
// OPEN resultContainerNode
resultContainerNode.containerOpen = true;
// Search results are now child items of this container?
for (var i = 0; i < resultContainerNode.childCount; ++i) {
    var childNode = resultContainerNode.getChild(i);
    if (childNode.type == childNode.RESULT_TYPE_URI) {
        console.log('childNode ' + i + ' is url = ', childNode)
        console.log('times visited = ', childNode.accessCount)
    }
    if (i >= 10) {
        break
    }
}

// CLOSE resultContainerNode
resultContainerNode.containerOpen = false;

gist is here: https://gist.github.com/Noitidart/9729440


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...