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?
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.
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.
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.
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.
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); });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With