0

I've been trying to figure out how one prints all the values in a specified folder from Google Chrome. Thus far, I've only been able to get it to create a folder with a name of my choice, but I can't access it.

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);
            });
        }
    });
}

Any help to be able to access/print the contents of a bookmark folder would be greatly appreciated! ;)

Thanks in advance!

For those interested:

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;
            }
        }
    });
}
GizmoRay
  • 1
  • 1
  • Why can't you access it? Is there any error? Seeing your code I am sure you already know how to reach your newly created folder in the hierarchy. – zambrey Feb 07 '14 at 16:00
  • I've tried several methods that are listed on Google's page, but they all come up blank, without any errors. Kind of at a loss! – GizmoRay Feb 08 '14 at 00:03
  • I wrote code doing something similar here. http://stackoverflow.com/a/20964407/2154178 See if that helps you. I didn't have any problem like yours. – zambrey Feb 08 '14 at 00:21
  • I actually figured it out on my own! Thanks a lot, guys! – GizmoRay Feb 08 '14 at 00:53
  • user3283704, please post your answer and accept it so that others in the future can benefit from your knowledge. This is a community site, not a tech-support forum! – sowbug Feb 09 '14 at 03:14
  • @sowbug, It is posted above, has been for ages! ;) – GizmoRay Feb 13 '14 at 06:32
  • You answer it, then, and I'll upvote your answer. The question remains unanswered. For those of us tracking unanswered question metrics, formalities matter. – sowbug Feb 13 '14 at 15:07

0 Answers0