views:

82

answers:

1

Hi. Is there any way to access cookies || localSorage from content script?

for example i have localStorage.shBox='true'

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

+2  A: 

In order to access extension's localStorage you need to send a request to your background 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"]);
    }
});

Cookies API is described in details here.

serg