Access localSorage cookies from script content - Chrome extension

Is there a way to access cookies || localSorage from content script ?

for example, I have localStorage.shBox = 'true'

and I want to access this from the script content .. how can I do this?

+3
source share
1 answer

To access the localStorage extension, you need to send a request to your home page:

In script.js:

chrome.extension.sendRequest("getStorageData", function(response) {
    console.log("response:", response);
}

In background.html:

chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
    if(request === "getStorageData") {
        sendResponse(localStorage["data"]);
    }
});

API cookie .

+4

Source: https://habr.com/ru/post/1759363/


All Articles