Scrapping with chrome extension can be fun, especially when you encounter platforms like
#Skool and
#Temu where the classes are rotated/scrambled. What's helped in my case are usually:
1. data-id
2. JSON Linked Data
3. Querying unique CSS stylings
Let's take Temu for context, most of Temu classes are scrambled and there's a general use of data-id so it's hard to pinpoint/make specific queries; leaving us with option 2 ( See attached image below)
HOWEVER
ContentScript can not read variables from the hostpage UNLESS the ContentScript is injected into host page using chrome.scripting.executeScript
Another Gotcha
Some CSP from the hostpage, can forbid you from injecting into the DOM e.g Instagram
(Attaching script into the head tag)
HOWEVER AGAIN
executeScript can allow you run in the host's context without the need to inject the script using the ScriptInjection.func;
this executes your code with the context of the hostpage, where the JSON can be accessed and stored to the localStorage, now because ContentScript and the Host page are attached to the same DOM,
they can both access the same localStorage or you can even use postMessage the host's DOM, and also use ContentScript to listen to onMessage on the same DOM to receive the data.
developer.chrome.com/docs/ex…
lol I haven't coded it yet but I've done this for the
#Skool platform to monkey patch the Fetch and Response object to retrieve channelID for mass messaging purposes.
#chromeextension