Get all keys from Chrome Storage

北城以北 提交于 2019-11-29 01:40:13

问题


I can get the value of a storage key with the Chrome Extension API:

chrome.storage.sync.get("someKey", function() {});

How can I get all key names that exist in the Chrome storage?


回答1:


From the documentation (emphasis mine):

An empty list or object will return an empty result object. Pass in null to get the entire contents of storage. Don't forget to change "storage.sync" to storage.local if you're using local storage.

For some example code:

chrome.storage.sync.get(null, function(items) {
    var allKeys = Object.keys(items);
    console.log(allKeys);
});


来源:https://stackoverflow.com/questions/18150774/get-all-keys-from-chrome-storage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!