Reputation: 1362
I need to know, if it´s possible in any way to store data from an chrome extension, which I can use on every website. I use the data in JS conent_scripts.
I tried cookies and iframe for localStorage workaround as desribed here: http://www.nczonline.net/blog/2010/09/07/learning-from-xauth-cross-domain-localstorage/
But nothing really worked. Please help me.
Edit: As written below in comments, it works now with chrome.storage. Thanks!
Edit2: This doesn´t work for me:
chrome.storage.sync.set({key: "test", value: "test Test 1234"},
function ()
{
console.log("had saved!");
chrome.storage.sync.get("test",
function (value)
{
console.log("read value: ", value);
}
);
}
);
The console output:
read value: Object {}
Upvotes: 5
Views: 3593
Reputation: 16020
The problem with your new code is the following:
chrome.storage.sync.set({test: "test Test 1234"}, function () {
console.log("had saved!");
chrome.storage.sync.get("test", function (value) { console.log("read value: ", value.test); } );
});
All objects are key-value pairs, you shouldn't add the key and value properties.
Upvotes: 1