Hi, I’ve been trying to develop a small extension to process bookmarks in a given folder, but without a lot of luck.
Since I’m new to WebExtensions (and only having a little previous experience with the legacy type) I thought I would start with trying to simply print out the list of bookmarks to the console and go from there.
I’m using chome.bookmarks, but the getTree method doesn’t seem to work - no errors. This bit of code is run from the background script.
function test_click(tab) {
console.log("Testing from background script!");
// Testing Bookmarks
var bookmarks = chrome.bookmarks;
//var bookmarks = browser.bookmarks;
bookmarks.getTree(function (bookmarks2) {
console.log(JSON.stringify(bookmarks2));
});
}
// Handle button click
chrome.browserAction.onClicked.addListener(test_click);
It’s triggered by an icon on the toolbar.
The first console log message output works, but nothing appears underneath it. When I debug it, it just skips through, as if no bookmarks were found, or something along those lines. But there are a lot of bookmarks and folders.
Other items of importance: The bookmarks permission is present in the manifest.json. If I don’t include this permission, I do get errors.
The same piece of code actually works ok in Chrome. Any ideas?
Regards,
Daniel