I have 4 items which I'd like to get but I'm unsure how to separate the keys. Using comma gives an error. Here is an example of my usage:
chrome.storage.sync.get({
'customImage',
'customColor',
'customRandColor',
'customRandImage'
}, function(backgroundCheckedOptions) {
document.getElementById('optionsCustomImage').checked = backgroundCheckedOptions.customImage;
document.getElementById('optionsBackgroundColor').checked = backgroundCheckedOptions.customColor;
document.getElementById('optionsRandomColor').checked = backgroundCheckedOptions.customRandColor;
document.getElementById('optionsRandomImage').checked = backgroundCheckedOptions.customRandImage;
});
I would have assumed they would be separated by a comma, but I guess 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.
Even if you're not actively using them, every open tab and enabled extension consumes disk space. It is easy to examine Chrome tabs and extensions that might be consuming too many resources in Chrome Task Manager.
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.
From the Chrome Storage documentation, it says:
StorageArea.get(string or array of string or object keys, function callback)
Easiest would be to pass an array by replacing your {}
with []
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