If i want to find all elements that are inside a box region, what is the best way to do it as a Firefox extension? If i check all leave elements and call getBoundingClientRect(), it’d be too slow given that there can easily be more than 500 leaves on a page.
Any help will be appreciated. Thanks.
You can use
document.elementFromPointand visit each fifth pixel (every fifth is much faster than visiting every single pixel), adding each found element to an array: