Reputation: 1907
As a simple example, let's say I want to insert a word at the bottom of every webpage, and I want the user to be able to change that word. So I have an options page (within the extension), within which I take user input and use it to call "localStorage.preferences = x;".
Next, the user navigates to http://www.google.com/, and I inject a script which writes the word found in localStorage.preferences. The problem is, since I'm now at a different domain, I'm seeing the localStorage for google.com, not my extension.
How can I share data between my extension's options page and a script injected into some 3rd-party webpage?
Upvotes: 0
Views: 871
Reputation: 3119
It's not, perhaps, the most direct response to your question, but one way to potentially get around this would be to use message passing to fake direct access to local storage from another domain. Assuming you're running your Javascript in the context of a content script, you could pass a message to the background page asking for a key, which would return the contents of localStorage
.
Upvotes: 2