Answer the question
In order to leave comments, you need to log in
How to get data in content script directly from chrome.storage?
Hello!
Faced such a problem: you need to get data from chrome.storage in the content script.
I know that it is possible to receive the data from storage through messages. But I need a function that would result in data from the storage. Those. this option is not suitable:
Content script
function get_data() {
chrome.runtime.sendMessage({}, function (data) {
window.data = data;
});
}
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
if(!chrome.storage.local['data'])
chrome.storage.local['data'] = 'Какие-то данные...';
sendResponse(chrome.storage.local['data']);
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question