Get the item currently under the mouse without using mouse events

WRT creates a Firefox add-on.

Is it possible to get an element under the mouse through some XPCOM or javascript method? (non-js-ctypes, as this requires OS specificity)

I want to determine what is under the mouse when the user clicks Ctrl+ Shift+ M.

At the moment, I am adding a listener mouseoverto the document when the user presses this hotkey, so I can get the element under the mouse when he moves it, but not the element that was under the mouse when he press the hotkey combination.

+4
source share
1

, ( ) . , ( Javascript, XPCOM ). , - ... MXR .

, mousemove ( ), , . .

function getInnermostHovered() {
    var n = document.querySelector(":hover");
    var nn;
    while (n) {
        nn = n;
        n = nn.querySelector(":hover");
    }
    return nn;
}

(fiddle, )

, , , , , pointer-events. , ...

, , (, ).

+10

Source: https://habr.com/ru/post/1546906/


All Articles