简体   繁体   English

如何从Chrome扩展程序访问本地存储?

[英]How to access local storage from chrome extension?

I have a web application that I'm writing a chrome extension for, and in this web application I save data to local storage. 我有一个要为其编写chrome扩展程序的Web应用程序,在此Web应用程序中,我将数据保存到本地存储中。 I am trying to access this data from a chrome extension, but none of these options are able to access the local storage that isn't associated with just the scope of the extension: 我正在尝试从chrome扩展访问此数据,但是这些选项都无法访问与扩展范围无关的本地存储:

localStorage.getItem
localStorage["itemName"]
chrome.storage.local.get function
chrome.storage.sync.get function

None of these methods have worked, as they all return "null" or "undefined" for items that I know exist in the localStorage that have been set from my web application. 这些方法都不起作用,因为对于我从Web应用程序设置的localStorage中存在的已知项,它们都返回“ null”或“ undefined”。 Can someone please help? 有人可以帮忙吗? I thought this would be a simple task but so far I can't solve it. 我认为这将是一个简单的任务,但到目前为止我还无法解决。

正如Jaromanda X和wOxxOm所指出的那样,使用内容脚本为我提供了解决此问题所需的访问权限-谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM