我一直在试图弄清楚如何从Google Chrome中打印指定文件夹中的所有值。到目前为止,我只能创建一个名称为我选择的文件夹,但我无法访问它。
function checkBookmarks() {
var folderName = 'Helium';
chrome.bookmarks.getChildren("1", function(children) {
var numChildren = children.length;
while (numChildren--) {
if (children[numChildren].title == folderName) {
folderId = children[numChildren].id;
break;
}
}
if (folderId === undefined) {
chrome.bookmarks.create({
parentId: "1",
title: folderName
}, function(folder) {
folderId = folder.id;
console.log(folderName + " not found and has been created at ID " + folder.id);
});
}
});
}
任何能够访问/打印书签文件夹内容的帮助将不胜感激! ;)
提前致谢!
对于那些感兴趣的人:
function populateBookmarks() {
var folderName = "Helium";
$("#marks").hide();
chrome.bookmarks.getChildren("1", function(children) {
var numChildren = children.length;
while(numChildren--) {
if(children[numChildren].title == folderName) {
var bookmarks = chrome.bookmarks.getChildren(children[numChildren].id, function(marks) {
// console.log(marks);
marks.forEach(function(links) {
var posthtml = '<tr><td><a href="' + links.url + '">'+ links.title +'</a></td></tr>';
$("#marks").children("tbody").append(posthtml);
$("#marks").show();
});
});
break;
}
}
});
}