我想编写一个示例扩展来使用 javascript 提供的一些 html 内容覆盖 newtab 页面。这个怎么做 ?Javascript 在此处提供 html 内容:
function getFavouriteWebsite() {
var historyService = Components.classes["@mozilla.org/browser/nav-history-service;1"].getService(Components.interfaces.nsINavHistoryService);
var query = historyService.getNewQuery();
var options = historyService.getNewQueryOptions();
options.queryType = 0;
options.sortingMode = options.SORT_BY_VISITCOUNT_DESCENDING;
options.maxResults = 6;
var result = historyService.executeQuery(query, options);
result.root.containerOpen = true;
var contentHtml ='';
for (var i = 0; i < result.root.childCount; i++) {
for (var i = 0; i < result.root.childCount; i++) {
contentHtml += "<p><a href=\"" + result.root.getChild(i).uri + "\">" + (result.root.getChild(i).title == "" ? result.root.getChild(i).uri : result.root.getChild(i).title) + "</a></p>";
}
}
return contentHtml;
}