本文介绍了扩展组件访问计数在Firefox的历史和书签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道哪个接口可以用来获取firefox的书签中每个
和 link
的访问计数历史
用于开发扩展
我试过使用 nav-history -service
获取书签和历史记录的链接,但无法弄清楚如何查看访问计数。 这里的代码将通过前10个书签entires。如果它是一个网址,它会检查它的 .accessCount
属性,它包含访问次数。
var hs = Cc [@ mozilla.org/browser/nav-history-service;1\"].getService(Ci.nsINavHistoryService);
var query = hs.getNewQuery();
var options = hs.getNewQueryOptions();
//查询用户书签,而不是历史
options.queryType = options.QUERY_TYPE_BOOKMARKS;
//执行搜索和存储结果
var result = hs.executeQuery(query,options);
//打开根容器节点并打开
var resultContainerNode = result.root;
//打开resultContainerNode
resultContainerNode.containerOpen = true;
//搜索结果现在是这个容器的子项目?
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;
要点在这里:
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.
解决方案
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
这篇关于扩展组件访问计数在Firefox的历史和书签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!