ulixee / hero

The web browser built for scraping
MIT License
696 stars 33 forks source link

feat(core): magic selectors #57

Closed blakebyrnes closed 2 years ago

blakebyrnes commented 2 years ago

NOTE: we should merge Pull Request 54 and 55 first.

This PR adds 2 functions to frameEnvironment/tab/hero:

magicSelector and magicSelectorAll These functions on their own simply allow a user to provide a list of selectors and verify that a querySelector (or querySelectorAll) returns the same elements from the provided list of querySelectors.

When a magicSelector is encountered, an event is broadcast at a tab level (magic-selector/magic-selector-all) with the options provided. Those options can be manipulated if need by (eg, by Superhero) to provide a larger list of querySelectors to test, or to trigger UI changes in Superhero.