Scripting 从内容脚本访问cookies | | localSorage-Chrome扩展

Scripting 从内容脚本访问cookies | | localSorage-Chrome扩展,scripting,cookies,google-chrome-extension,local-storage,Scripting,Cookies,Google Chrome Extension,Local Storage,有没有办法从内容脚本访问cookies|本地排序 例如,我有localStorage.shBox='true' 我想从内容脚本访问此内容。。如何进行此操作?要访问扩展的本地存储,您需要向后台页面发送请求: 在script.js中: chrome.extension.sendRequest("getStorageData", function(response) { console.log("response:", response); } 在background.html中: chro

有没有办法从内容脚本访问cookies|本地排序

例如,我有localStorage.shBox='true'


我想从内容脚本访问此内容。。如何进行此操作?

要访问扩展的本地存储,您需要向后台页面发送请求:

在script.js中:

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

chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
    if(request === "getStorageData") {
        sendResponse(localStorage["data"]);
    }
});
CookiesAPI的详细描述