I am interested in retrieving the element that is selected when right-clicking on "Inspect Element" using Javascript.
When we move the mouse around with the "Inspect" mode enabled, the selected area is shown within the web page UI and can be modified by mouse movements, indicating it should be accessible through js.
One possible solution would be to add a mouseover
event to all DOM elements and use it to determine the current element the mouse is hovering over. However, if Chrome developer tools are already doing something similar, I would prefer to utilize that method to obtain the element instead of adding event listeners to each element on the page.
Essentially, my idea involves calling:
inspect(document.body);
and then dynamically obtaining the element the mouse is currently hovering over through javascript. I am unsure of how to access it or whether it is even feasible.