bookmarks
{{AddonSidebar}}
The WebExtensions bookmarks
API lets an extension interact with and manipulate the browser’s bookmarking system. You can use it to bookmark pages, retrieve existing bookmarks, and edit, remove, and organize bookmarks.
To use this API, an extension must request the “bookmarks” permission in its manifest.json
file.
Extensions cannot create, modify, or delete bookmarks in the root node of the bookmarks tree. Doing so causes an error with the message: “The bookmark root cannot be modified”
Types
{{WebExtAPIRef("bookmarks.BookmarkTreeNode")}}
- : Represents a bookmark or folder in the bookmarks tree.
{{WebExtAPIRef("bookmarks.BookmarkTreeNodeType")}}
- : A
{{jsxref("String")}}
enum which describes whether a node in the tree is a bookmark, a folder, or a separator.
- : A
{{WebExtAPIRef("bookmarks.BookmarkTreeNodeUnmodifiable")}}
- : A
{{jsxref("String")}}
enum which specifies why a bookmark or folder is unmodifiable.
- : A
{{WebExtAPIRef("bookmarks.CreateDetails")}}
- : Contains information which is passed to the
{{WebExtAPIRef("bookmarks.create()")}}
function when creating a new bookmark.
- : Contains information which is passed to the
Functions
{{WebExtAPIRef("bookmarks.create()")}}
- : Creates a bookmark or folder.
{{WebExtAPIRef("bookmarks.get()")}}
- : Retrieves one or more
{{WebExtAPIRef("bookmarks.BookmarkTreeNode", "BookmarkTreeNode")}}
s, given a bookmark’s ID or an array of bookmark IDs.
- : Retrieves one or more
{{WebExtAPIRef("bookmarks.getChildren()")}}
- : Retrieves the children of the specified
{{WebExtAPIRef("bookmarks.BookmarkTreeNode", "BookmarkTreeNode")}}
.
- : Retrieves the children of the specified
{{WebExtAPIRef("bookmarks.getRecent()")}}
- : Retrieves a requested number of recently added bookmarks.
{{WebExtAPIRef("bookmarks.getSubTree()")}}
- : Retrieves part of the bookmarks tree, starting at the specified node.
{{WebExtAPIRef("bookmarks.getTree()")}}
- : Retrieves the entire bookmarks tree into an array of
{{WebExtAPIRef("bookmarks.BookmarkTreeNode", "BookmarkTreeNode")}}
objects.
- : Retrieves the entire bookmarks tree into an array of
{{WebExtAPIRef("bookmarks.move()")}}
- : Moves the specified
{{WebExtAPIRef("bookmarks.BookmarkTreeNode", "BookmarkTreeNode")}}
to a new location in the bookmark tree.
- : Moves the specified
{{WebExtAPIRef("bookmarks.remove()")}}
- : Removes a bookmark or an empty bookmark folder, given the node’s ID.
{{WebExtAPIRef("bookmarks.removeTree()")}}
- : Recursively removes a bookmark folder; that is, given the ID of a folder node, removes that node and all its descendants.
{{WebExtAPIRef("bookmarks.search()")}}
- : Searches for
{{WebExtAPIRef("bookmarks.BookmarkTreeNode", "BookmarkTreeNode")}}
s matching a specified set of criteria.
- : Searches for
{{WebExtAPIRef("bookmarks.update()")}}
- : Updates the title and/or URL of a bookmark, or the name of a bookmark folder, given the bookmark’s ID.
Events
{{WebExtAPIRef("bookmarks.onCreated")}}
- : Fired when a bookmark or folder is created.
{{WebExtAPIRef("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.
{{WebExtAPIRef("bookmarks.onChanged")}}
- : Fired when a bookmark or folder changes. Currently, only
title
andurl
changes trigger this.
- : Fired when a bookmark or folder changes. Currently, only
{{WebExtAPIRef("bookmarks.onMoved")}}
- : Fired when a bookmark or folder is moved to a different parent folder or to a new offset within its folder.
{{WebExtAPIRef("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
{{WebExtAPIRef("bookmarks.move", "move()")}}
.
- : 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
{{WebExtAPIRef("bookmarks.onImportBegan")}}
- : Fired when a bookmark import session is begun. Expensive observers should ignore
{{WebExtAPIRef("bookmarks.onCreated")}}
updates until{{WebExtAPIRef("bookmarks.onImportEnded")}}
is fired. Observers should still handle other notifications immediately.
- : Fired when a bookmark import session is begun. Expensive observers should ignore
{{WebExtAPIRef("bookmarks.onImportEnded")}}
- : Fired when a bookmark import session has finished.
Browser compatibility
{{Compat}}
{{WebExtExamples("h2")}}
[!NOTE] This API is based on Chromium’s
chrome.bookmarks
API. This documentation is derived frombookmarks.json
in the Chromium code.