0

My Chrome Extension has a background script as well as a content script. The content script redirects to a new page (www.nike.com). The page adds 3 domains and a some data to the local storage. I want to access one of the domains storage.

I tried to use the Chrome.storage API inside my background script and in my content script, but I always receive an empty object.

I also added the onChange event listener, but this wasn't successful too. It seems that the local storage is empty. Is it even possible to access exactly this storage?

enter image description here

DJY
  • 35
  • 5
  • `wndow.localStorage` is a different storage not related to `chrome.storage`. Devtools shows only the former in Chrome. You need to use a content script to read the site's `localStorage`. – wOxxOm Jul 03 '21 at 17:26
  • I used chrome.storage.local, which should be able to find the keys I am searching for. I implemented it into the content script as you told, but it did not work. Instead it's empty, even with the onChange listener in the content script. – DJY Jul 03 '21 at 18:34
  • Ah, chrome.storage.local is not equal to window.localStorage. And in my extension I have to use window.localStorage to get the data I need? – DJY Jul 03 '21 at 18:40
  • I believe my comment above already contains an answer. – wOxxOm Jul 04 '21 at 03:35

1 Answers1

-1

Local storage is a property of the domain, and since both these domains are different you won't be able to access it.

Check this out: Accessing iframe's parent localstorage variable from iframe

ravvis
  • 99
  • 1
  • 4