Domanda

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?

È stato utile?

Soluzione

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);
});
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top