I'm designing my first chrome extension and have run into a problem.
On my popups.js users can enter words and definitions that are saved as an array in chrome storage:
function save()
{
chrome.storage.local.set({'words': words});
chrome.storage.local.set({'definitions': definitions});
}
I would like to then load these words and definitions in my content script js like so:
function load()
{
//load words from local storage
chrome.storage.local.get('words', function (result) {
if (result.words != "null") words = result.words;
});
//load definitions
chrome.storage.local.get('definitions', function (result) {
if (result.definitions != "null") definitions = result.definitions;
});
}
However it does not load the data at all. I have made sure the data is saved before the content script is run.
I have looked into messaging but don't really understand it / know if that's even the right way to do it.
Help appreciated!