Reputation: 21
I've seen similar questions but the slight difference in what they wanted caused me to fail to convert it to what I want.
I want to be able to fetch info such as background color from the web page into the extension and be able to work with it in the extension. I already have writing to the page down, but not so much on receiving data from it.
From what I understood, get and sendRequest was for interaction between files in the extension, not for interaction with the page.
Upvotes: 2
Views: 1922
Reputation: 13614
get
and sendRequest
are used to pass information between so-called content scripts and background scripts. Content scripts have access to the DOM of the allowed pages but can't do arbitrary AJAX lookups, while background scripts can't access the DOM of allowed pages.
For your problem, it sounds like you can solve it in a content script. That page should tell you the relevant parts of the manifest.json
you need to add, and with that you tell Chrome to load certain CSS override files as well as JS files you might need if the URL matches a pattern in matches
. If you're doing AJAX requests, you'll need to request permissions in manifest.json
, run JS that gets your results, and use message passing to pass that information from the background script to a content script that can handle it.
Upvotes: 2