Reputation: 41
I read the MDN documentation about how to get a reference to the bookmarks tree und to navigate within. But how do I know which folder represents the bookmarks toolbar? This toolbar is named differently depending on the locale. I am not sure whether a user is still allowed to select an arbitrary folder for this, but this was possible some years ago.
I found this post: Programmatically bookmark pages in bookmark toolbar using firefox extension
but this is not about the new webextension API that everybody has to use now.
Upvotes: 3
Views: 296
Reputation: 77523
As per comments, there are special IDs you can search for.
// If you just need the node or its contents
let toolbar_node = await browser.bookmarks.get("toolbar_____");
let toolbar_subtree = await browser.bookmarks.getSubTree("toolbar_____");
// If you're walking the tree on your own
if (node.id == "toolbar_____") { /* it's the toolbar */ }
They were apparently introduced in https://bugzilla.mozilla.org/show_bug.cgi?id=1071505 4 years ago, to be generally used by other Firefox subsystems as hardcoded values. While that can change, it's unlikely and would have be for a good reason because of all pre-existing dependencies elsewhere.
That said, their use in WebExtensions is not documented.
Upvotes: 1