Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get all keys from Chrome Storage

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?

like image 363
Ali Esmailian Avatar asked Aug 09 '13 15:08

Ali Esmailian


People also ask

How do I access my Google Chrome storage?

With the extension's background page open, just go to the developer tools by pressing F12, then go to the Application tab. In the Storage section expand Local Storage. After that, you'll see all your browser's local storage there.

Can content scripts access Chrome storage?

Therefore, if you're accessing localStorage from your contentscript, it will be the storage from that webpage, not the extension page storage. Now, to let your content script to read your extension storage (where you set them from your options page), you need to use extension message passing. chrome.

Is Chrome local storage encrypted?

When storing this extra-sensitive data, Chromium encrypts it using AES256 on Windows (AES128 on Linux/Mac), storing the encryption key in an OS storage area. This feature is called local data encryption. Not all of the browser's data stores use encryption– for instance, the browser cache does not.

Where do Chrome extensions save data?

When extensions are installed into Chrome they are extracted into the C:\Users\[login_name]\AppData\Local\Google\Chrome\User Data\Default\Extensions folder. Each extension will be stored in its own folder named after the ID of the extension.


1 Answers

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); }); 
like image 86
Rob W Avatar answered Sep 30 '22 00:09

Rob W