简体   繁体   中英

How to access chrome.bookmarks in Chrome Console

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?

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 (eg 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:

访问<code> chrome.bookmarks </ code>的示例

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM