function getHistoryByTime(days) {
var historySvc = Components.classes["@mozilla.org/browser/nav-history-service;1"].getService(Components.interfaces.nsINavHistoryService);
if (days == null || days == undefined) {
days = 7;
}
var list = new Array();
var query = historySvc.getNewQuery();
query.searchTerms = "firefox";
var query2 = historySvc.getNewQuery();
query2.beginTimeReference = query2.TIME_RELATIVE_NOW;
query2.beginTime = -24 * parseInt(days) * 60 * 60 * 1000000;
query2.endTimeReference = query2.TIME_RELATIVE_NOW;
query2.endTime = 0;
var options = historySvc.getNewQueryOptions();
options.sortingMode = historySvc.SORT_BY_VISITCOUNT_DESCENDING;
options.queryType = historySvc.QUERY_TYPE_HISTORY;
options.maxResults = 10;
options.resultType = historySvc.RESULTS_AS_VISIT;
var result = historySvc.executeQueries([query, query2], 2, options);
var cont = result.root;
cont.containerOpen = true;
for (var i = 0; i < cont.childCount; i++) {
var node = cont.getChild(i);
if (node != null && node != undefined) {
if (node.uri && !node.uri.indexOf("file") == 0) {
var entry = {
title: node.title == null ? node.uri : node.title,
pic: "",
icon: node.icon,
url: node.uri
};
list.push(entry);
}
}
}
cont.containerOpen = false;
return list;
}