My extension popup page gets data from a message from a sand-boxed page & scripts. I need to store this inside the chrome.storage, preferably using the storage.sync method. I'm getting this error: Uncaught TypeError: Cannot read property 'sync' of undefined
I already added the permissions for storage inside my manifest.json.
... "permissions": ["storage"], ... chrome.storage.sync undefined?
Google alsostates that no backgroud script is needed: https://developer.chrome.com/extensions/storage
Quoting: Your extension's content scripts can directly access user data without the need for a background page.
What am I overlooking? Thanks in advance!
function receiveMessage(event) {
var data = event.data;
saveToStorage(data);
};
window.addEventListener("message", receiveMessage, false);
function saveToStorage(data)
{
if (!data) {
console.log('Error: No value specified. Nothing saved to storage.');
return;
}
chrome.storage.sync.set({'data': data}, function() {
console.log('Data saved to storage.');
});
};