有什么方法可以访问cookie ||来自内容脚本的localSorage?
例如我有localStorage.shBox='true'
我想从内容脚本访问它..我该如何制作它?
最佳答案
为了访问扩展程序的 localStorage,您需要向后台页面发送请求:
在 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"]);
}
});
Cookies API详细说明here .
关于scripting - 访问 cookie ||来自内容脚本的 localSorage - Chrome 扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3469499/