We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trying to use storage.get() in a content script results in Access to storage is not allowed from this context. Here's my code:
storage.get()
Access to storage is not allowed from this context.
// content.ts const storage = new Storage({ area: "session" }) const init = async () => { value = await storage.get("key") } init()
I can't call storage.get() outside an async function so am I doing something wrong?
The text was updated successfully, but these errors were encountered:
The session area is relatively new (introduced in Chrome 102). I suspect some unique property of session-type storage causes this.
Sorry, something went wrong.
From the docs
By default, it's not exposed to content scripts, but this behavior can be changed by setting chrome.storage.session.setAccessLevel().
setAccessLevel isn't supported in Plasmo so you need to call it from the browser storage api.
setAccessLevel
// background.ts (async () => { const storage = new Storage({ area: "session" }) const extStorageApi = storage.getExtStorageApi() await extStorageApi.session.setAccessLevel({ accessLevel: "TRUSTED_AND_UNTRUSTED_CONTEXTS" }) })()
No branches or pull requests
Trying to use
storage.get()
in a content script results inAccess to storage is not allowed from this context.
Here's my code:
I can't call
storage.get()
outside an async function so am I doing something wrong?The text was updated successfully, but these errors were encountered: