2

I have read google's developer chrome.bookmarks doc and googled it, still can't find a way to access chrome.bookmarks in Chrome Console.

But I do can access chrome in Chrome Console

console.log(chrome) //run this in Chrome Console
// Object {app: Object, webstore: Object, runtime: Object, loadTimes: function, csi: function}

But try access chrome.bookmarks the same way, returned print undefined

console.log(chrome.bookmarks)

any suggestion?

Fangxing
  • 5,716
  • 2
  • 49
  • 53
  • Include the manifest in your question. – Josh Lee Apr 20 '17 at 15:16
  • 1
    Are you looking at the console in a page with a `chrome-extension://...` URL? Does your extension have the `bookmarks` permission? – apsillers Apr 20 '17 at 15:21
  • @Josh Lee Sorry, I didn't make it clear, I have edited the question again. I mean access chrome.bookmarks in Chrome Console, not in a chrome extension. – Fangxing Apr 20 '17 at 15:22
  • 1
    Yes, the documentation you linked to makes clear that this is an API for chrome extensions to use. – Josh Lee Apr 20 '17 at 15:23
  • 1
    Possible duplicate of [Chrome API is undefined](http://stackoverflow.com/questions/25437648/chrome-api-is-undefined) – Josh Lee Apr 20 '17 at 15:41

1 Answers1

1

There are multiple consoles for your extension. To access chrome.bookmarks from the console, you will need to be using a DevTools which is associated with a page in the background context (e.g. the background page, or popup, etc.). You will also need to have declared the bookmarks permission in your manifest.json.

Example of accessing chrome.bookmarks from the background page's DevTools:

Example of accessing <code>chrome.bookmarks</code>

Community
  • 1
  • 1
Makyen
  • 31,849
  • 12
  • 86
  • 121