Interact with the browser's bookmarking system: bookmark pages, retrieve existing bookmarks, edit, remove, and organize bookmarks.
To use this API you need to have the "bookmarks" permission.
Types
bookmarks.BookmarkTreeNodeUnmodifiable
- Indicates the reason that a bookmark or folder is unmodifiable.
bookmarks.BookmarkTreeNode
- Represents a bookmark or a folder in the bookmarks tree.
bookmarks.CreateDetails
- Object passed to the
bookmarks.create()
function.
Functions
bookmarks.get()
- Retrieves the specified
BookmarkTreeNode(s)
. bookmarks.getChildren()
- Retrieves the children of the specified
BookmarkTreeNode
. bookmarks.getRecent()
- Retrieves recently added bookmarks.
bookmarks.getTree()
- Retrieves the entire bookmarks tree.
bookmarks.getSubTree()
- Retrieves part of the bookmarks tree, starting at the specified node.
bookmarks.search()
- Searches for
BookmarkTreeNodes
matching the given query. bookmarks.create()
- Creates a bookmark or folder under the specified
parentId
. bookmarks.move()
- Moves the specified
BookmarkTreeNode
to the provided location. bookmarks.update()
- Update the title or URL of a bookmark, or the name of a bookmark folder.
bookmarks.remove()
- Removes a bookmark or an empty bookmark folder.
bookmarks.removeTree()
- Recursively removes a bookmark folder.
bookmarks.import()
- Imports bookmarks from an HTML bookmark file.
bookmarks.export()
- Exports bookmarks to an HTML bookmark file.
Events
bookmarks.onCreated
- Fired when a bookmark or folder is created.
bookmarks.onRemoved
- Fired when a bookmark or folder is removed. When a folder is removed recursively, a single notification is fired for the folder, and none for its contents.
bookmarks.onChanged
- Fired when a bookmark or folder changes. Currently, only
title
andurl
changes trigger this. bookmarks.onMoved
- Fired when a bookmark or folder is moved to a different parent folder.
bookmarks.onChildrenReordered
- Fired when the user has sorted the children of a folder in the browser's UI. This is not called as a result of a
move()
. bookmarks.onImportBegan
- Fired when a bookmark import session is begun. Expensive observers should ignore
bookmarks.onCreated
updates untilbookmarks.onImportEnded
is fired. Observers should still handle other notifications immediately. bookmarks.onImportEnded
- Fired when a bookmark import session has finished.
Browser compatibility
Edge | Firefox | Chrome | Opera | |
---|---|---|---|---|
BookmarkTreeNode | ? | 45.0 | Yes | 33 |
BookmarkTreeNodeUnmodifiable | ? | 45.0 | Yes | 33 |
CreateDetails | ? | 45.0 | Yes | 33 |
create | ? | 45.0 | Yes | 33 |
export | ? | No | Yes | 33 |
get | ? | 45.0 | Yes | 33 |
getChildren | ? | 45.0 | Yes | 33 |
getRecent | ? | 47.0 | Yes | 33 |
getSubTree | ? | 45.0 | Yes | 33 |
getTree | ? | 45.0 | Yes | 33 |
import | ? | No | Yes | 33 |
move | ? | 45.0 | Yes | 33 |
onChanged | ? | No | Yes | 33 |
onChildrenReordered | ? | No | Yes | 33 |
onCreated | ? | No | Yes | 33 |
onImportBegan | ? | No | Yes | 33 |
onImportEnded | ? | No | Yes | 33 |
onMoved | ? | No | Yes | 33 |
onRemoved | ? | No | Yes | 33 |
remove | ? | 45.0 | Yes | 33 |
removeTree | ? | 47.0 | Yes | 33 |
search | ? | 47.0 | Yes | 33 |
update | ? | 45.0 | Yes | 33 |
Firefox | |
---|---|
BookmarkTreeNode | No |
BookmarkTreeNodeUnmodifiable | No |
CreateDetails | No |
create | No |
export | No |
get | No |
getChildren | No |
getRecent | No |
getSubTree | No |
getTree | No |
import | No |
move | No |
onChanged | No |
onChildrenReordered | No |
onCreated | No |
onImportBegan | No |
onImportEnded | No |
onMoved | No |
onRemoved | No |
remove | No |
removeTree | No |
search | No |
update | No |
The "Chrome incompatibilities" section is included from https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities using the WebExtChromeCompat macro.
If you need to update this content, edit https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities, then shift-refresh this page to see your changes.
Chrome incompatibilities
- Firefox does not support:
import()
export()
onCreated
onRemoved
onChanged
onMoved
onChildrenReordered
onImportBegan
onImportEnded
BookmarkTreeNodeUnmodifiable
- Firefox has special bookmarks like "Recently Bookmarked" or "Recently Visited"
Example add-ons
Acknowledgements
This API is based on Chromium's chrome.bookmarks
API. This documentation is derived from bookmarks.json
in the Chromium code.
// Copyright 2015 The Chromium Authors. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.