Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to grab a react element in chrome extension?

If a website uses react, how can i grab an element by class?

For example here is a div:

<div class="Blockreact__Block-sc-1xf18x6-0 Flexreact__Flex-sc-1twd32i-0 IgxsY jYqxGr"></div>

How can i grab this div with javascript everytime, if the website gets built again?
If im correct the react classes are always different after every build, or will it stay the same always?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If the classes assigned to the element you want are unpredictable then you need to change your approach to finding the element.

For example, you might look for an element which is the third next sibling of the first h1 in the document.

The specifics depend on the precise nature of the DOM you are dealing with.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading