Questions tagged [google-chrome-storage]

chrome.storage is a more powerful chrome-only alternative to localStorage. It can store objects (not just strings) and can be synchronized with Chrome sync.

The chrome.storage API provides the same storage capabilities as the localStorage API with the following key differences:

  • User data can be automatically synced with Chrome sync (using storage.sync).
  • Your extension's content scripts can directly access user data without the need for a background page.
  • A user's extension settings can be persisted even when using split incognito behavior.
  • It's asynchronous with bulk read and write operations, and therefore faster than the blocking and serial localStorage API.
  • User data can be stored as objects (the localStorage API stores data in strings).
  • Enterprise policies configured by the administrator for the extension can be read (using storage.managed with a schema).
177 questions
66
votes
5 answers

chrome.storage.sync undefined?

I'm trying to use chrome storage in an extension, via a content_script, but I keep failing on Uncaught TypeError: Cannot read property 'sync' of undefined This is my code: testChromeStorage(); function testChromeStorage() { …
Yossale
  • 14,165
  • 22
  • 82
  • 109
64
votes
2 answers

window.localStorage vs chrome.storage.local

I'm developing a Chrome extension and I need to store some data and then get it in some point. I did investigation on available storages and came across to the following ones: window.localStorage and chrome.storage.local. So my question is, which…
59
votes
1 answer

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?
43
votes
6 answers

Returning Chrome storage API value without function

For the past two days I have been working with chrome asynchronous storage. It works "fine" if you have a function. (Like Below): chrome.storage.sync.get({"disableautoplay": true}, function(e){ console.log(e.disableautoplay); }); My problem is that…
27
votes
3 answers

Inspect extension's chrome.storage in devtools

Chrome DevTools has a handy inspector for Local Storage and Session Storage, but is there nothing to inspect chrome.storage.sync? chrome://sync-internals/ doesn't seem to display the actual contents of the synchronized storage per extension.
Dan Dascalescu
  • 143,271
  • 52
  • 317
  • 404
19
votes
2 answers

Getting Multiple items from Chrome storage?

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' …
Jamie
  • 421
  • 4
  • 17
16
votes
2 answers

Uncaught TypeError: Cannot read property 'local' of undefined in chrome extension

I have written a Chrome extension. I cannot use localStorage.setItem and localStorage.getItem for storing and retrieving because background and browser action runs in different environment [as seen here]. So I decided to use the Chrome storage…
12
votes
3 answers

How to wait for asynchronous chrome.storage.local.get() to finish before continuing execution

I have two calls to chrome.storage.local.get(). I need for these calls to finish before continuing executing the rest of the code (calling continueCode() function) for my chrome extension, but I'm not sure how to do this, here is my code. function…
nosh
  • 620
  • 3
  • 14
  • 50
11
votes
2 answers

chrome storage onChanged - between extension's background and popup

I would like to store a setting of my extension - being changed by the popup: chrome.storage.local.set({'extension-status': 'on'}, function() { console.log('extension on status stored'); } And receive update in my bakground page when this…
nagy.zsolt.hun
  • 6,292
  • 12
  • 56
  • 95
11
votes
2 answers

Chrome.Storage.Local Persistence

all. I've started developing small extensions using Chrome's various API's, and although things are working great, I'm still curious about a few things. Two questions, if you all wouldn't mind helping me out: 1. Could someone tell me what the limits…
8
votes
2 answers

Retrieving Date object from chrome storage not working

In a Chrome Extension, I'm trying to save a Date object to storage then read it back. According to the official documentation, Values with a typeof "object" and "function" will typically serialize to {}, with the exception of Array (serializes…
8
votes
1 answer

chrome sync storage to store and update array

is it possible to store array in chrome storage sync and retrieve them ? var uarray = [abc,def,ghi]; Is it possible to update the stored array in the storage ? var tobeadded = jkl; uarray.push(tobeadded); this was the syntax in…
Gomathi Sankar
  • 217
  • 1
  • 3
  • 15
8
votes
1 answer

chrome.storage set\get clarification

I want to save information in my extenstion. I use Chrome.storage.sync to do that, however when I read right after saving I am unable to rightly retrieve the value. Probably doing something stupid.... I tried clearing the local storage with…
7
votes
2 answers

How do I use Promise.all() with chrome.storage()?

I have several async functions running. I want to wait for them all to finish before taking the next steps. Here's my code that I'm using to get all of the key/values from chrome.storage and the Promise.all() implementation. var promise1 =…
7
votes
1 answer

chrome.storage.sync doesn't sync between machines

I have a simple extensions that saves some data to chrome storage var dt = new Date(); var item = {}; item[$('#qteSymb').text() + "-" + guid()] = $('#newnote').val() + "-:-" + $.datepicker.formatDate('mm/dd/yy', dt) + " " + dt.getHours() + ":" +…
americanslon
  • 4,048
  • 4
  • 32
  • 57
1
2 3
11 12