0

I'm coding an extension which downloads a file, before downloading the file, I need to get a token which is already generated from the website on loading. This token can be viewed from the console by typing >GetPublicTokenResult

How can I read this variable into my content script?

I've tried the following:

chrome.storage.local.get(["GetPublicTokenResult"], function(items){ items = [ { "yourBody": "myBody" } ]
console.log(items);
});

but it seems that this variable is not stored in Storage, but it can be viewed in Memory snap

Nightcap79
  • 620
  • 7
  • 13
  • You need a ["page script" to access page variables](/a/9517879) + [another example](/a/46870005). – wOxxOm Sep 28 '19 at 12:45

1 Answers1

0

Content scripts run in an isolated environment from the page. They can only interact with the DOM, javascript code can't be accesed. You need to inject your code directly in the page. Check out Insert code into the page context using a content script for a detailed tutorial.

Javier Silva Ortíz
  • 2,864
  • 1
  • 12
  • 21