Firefox Addon bookmarks group (subfolder) search: discriminating between bookmarks and groups

I’m trying to make my first firefox addon.
For this I want to get all the groups directly under the TOOLBAR group.
I started here, but didn’t manage to discriminate between groups and bookmarks.
Here is the relevant part of my code:

var { search, TOOLBAR } = require("sdk/places/bookmarks");
search(
    { group: TOOLBAR, type: "group" },
    { sort: "title" }
).on("end", function (results) {
    var arrayLength = results.length;
    console.log(arrayLength);
    for (var i = 0; i < arrayLength; i++) {
        console.log(results[i]);
        //Do something
    }
});

I would be interested in how to do this using the linked API.
If this wouldn’t work for some reason, I would also be interested in workarounds, older methods, more complicated or direct methods. In this case, please direct me to information that is roocky-proof 🙂


Source: bookmarks

Leave a Reply