Access webpage's localStorage from a Chrome ex

2019-06-16 15:31发布

问题:

i'm developing a chrome extension which requires to get the values(to plugin) from local storage where values are stored by some other webpages that were created by me

In short: Access a webpage's localStorage from a Chrome extension script

回答1:

I just tested it, and if you access localStorage from the context of a content script, you get the webpage's localStorage. So, nothing special is required besides injecting a content script into the webpage you need.

To communicate the value from the content script you can use Messaging API, and you can use chrome.storage.local API to save data in a way that's accessible from both the content script and the background page.