Use the chrome.bookmarks
API to create, organize, and otherwise manipulate bookmarks.
[PENDING: intro goes here...]
Bookmark objects are an important part of the chrome.bookmarks
API.
Each bookmark object represents either a URL or a group of bookmarks, as you can see in the following figure.
Objects that represent bookmarks can have the following properties:
id
title
parentId
(omitted for the root group)
index
(optional; omitted for the root group)
url
(omitted for groups)
The following code creates a bookmark group with the title "Chromium bookmarks". The last argument defines a function to be executed after the folder is created.
chrome.bookmarks.create({'parentId': bookmarkBar.id, 'title': 'Chromium bookmarks'}, function(newFolder) {...});
The next snippet creates a bookmark pointing to the Chromium developer doc. Since nothing too bad will happen if creating the bookmark fails, this snippet doesn't bother to define a callback function.
chrome.bookmarks.create({'parentId': chromiumBookmarks.id, 'title': 'dev doc', 'url': 'http://dev.chromium.org'});
Say you have bookmark hierarchy that looks like this:
Here's how those bookmarks might be represented with bookmark objects:
Here's some code you could use to create that hierarchy:
...code goes here...