Movatterモバイル変換


[0]ホーム

URL:


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

bookmarks.getRecent()

Thebookmarks.getRecent() method retrieves a specified number of the most recently added bookmarks as an array ofBookmarkTreeNode objects.

This is an asynchronous function that returns aPromise.

Syntax

js
let gettingRecent = browser.bookmarks.getRecent(  numberOfItems          // integer)

Parameters

numberOfItems

A number representing the maximum number of items to return. The returned list will contain up to this many of the most recently added items. The minimum allowed value here is 1. If you pass 0 or less, the function will throw an error.

Return value

APromise that will be fulfilled with an array ofBookmarkTreeNode objects.

Examples

This example logs the URL for the most recently added bookmark:

js
function onFulfilled(bookmarks) {  for (const bookmark of bookmarks) {    console.log(bookmark.url);  }}function onRejected(error) {  console.log(`An error: ${error}`);}browser.bookmarks.getRecent(1).then(onFulfilled, 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