Yes, Chrome extensions can modify shared storage, but the exact method depends on what you mean by "shared storage." There are a few interpretations:
1. Shared Storage API (Web Platform)
This is a web API, not an extension API. It allows sites to store and access unpartitioned cross-site data in a privacy-preserving way.
- Extensions cannot directly access the Shared Storage API used by websites.
- However, content scripts injected into web pages can interact with the Shared Storage API as if they were part of the page, because they run in the page's context.
Example:
If a website uses:
await sharedStorage.set('key', 'value');
A content script injected into that page can read or modify it using the same API.
2. Chrome Extension Storage APIs
These are extension-specific and not shared with websites or other extensions unless explicitly allowed.
chrome.storage.local – local to the extension
chrome.storage.sync – synced across user’s devices
chrome.storage.session – in-memory, session-only
These are not shared between extensions unless:
- You use extension messaging (
chrome.runtime.sendMessage) to coordinate between extensions.
- You use
chrome.storage with unlimitedStorage permission and manage access via a shared extension ID or service.
3. Shared Between Extensions (Cross-Extension Storage)
Extensions can share storage indirectly using:
- Native Messaging to a native app that manages shared data
- External extension messaging via
chrome.runtime.sendMessage or chrome.runtime.connect
- Shared origin access (e.g., if both extensions inject content scripts into the same page and use
window.postMessage or DOM storage)
Summary Table
| Storage Type | Shared With Websites | Shared With Other Extensions | Extension Can Modify |
|---|
| Shared Storage API | ✅ (cross-site) | ❌ | ✅ via content script |
chrome.storage.local | ❌ | ❌ | ✅ |
chrome.storage.sync | ❌ | ❌ | ✅ |
localStorage (page) | ✅ (same origin) | ❌ | ✅ via content script |
| Cross-extension messaging | ❌ | ✅ | ✅ |
If You Mean: "Can extensions modify the Shared Storage API used by websites?"
Yes, but only via content scripts that run in the context of the page and use the same sharedStorage API as the site.
Let me know which use case you're targeting — I can give you a code example.