Movatterモバイル変換


[0]ホーム

URL:


  1. Mozilla
  2. Add-ons
  3. Browser extensions
  4. JavaScript APIs
  5. bookmarks
  6. bookmarks.getTree()

bookmarks.getTree()

bookmarks.getTree() returns an array containing the root of the bookmarks tree as abookmarks.BookmarkTreeNode object.

You can access the entire tree recursively using itschildren property and thechildren property of its descendants, if they are themselves folders.

This is an asynchronous function that returns aPromise.

Syntax

js
let gettingTree = browser.bookmarks.getTree()

Parameters

None.

Return value

APromise that will be fulfilled with an array containing one object, abookmarks.BookmarkTreeNode object representing the root node.

Examples

This example prints out the entire bookmarks tree:

js
function makeIndent(indentLength) {  return ".".repeat(indentLength);}function logItems(bookmarkItem, indent) {  if (bookmarkItem.url) {    console.log(makeIndent(indent) + bookmarkItem.url);  } else {    console.log(`${makeIndent(indent)}Folder`);    indent++;  }  if (bookmarkItem.children) {    for (const child of bookmarkItem.children) {      logItems(child, indent);    }  }  indent--;}function logTree(bookmarkItems) {  logItems(bookmarkItems[0], 0);}function onRejected(error) {  console.log(`An error: ${error}`);}let gettingTree = browser.bookmarks.getTree();gettingTree.then(logTree, onRejected);

Browser compatibility

Note:This API is based on Chromium'schrome.bookmarks API. This documentation is derived frombookmarks.json in the Chromium code.

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp