Well, after some research I got to conclusion, that using a mutation observer is a way to go.
Here is a solution I'm happy with, for anyone else, who would stack to to same problem:
MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
const observer = new MutationObserver(function (mutations, observer) {
// fired when a mutation occurs
(function () {
const selector = document.querySelector('#selectorId');
if (selector) {
selector.addEventListener('mouseenter', e => {
e.stopPropagation();
alert('bbb');
}, false);
}
})();
});
// define what element should be observed by the observer
// and what types of mutations trigger the callback
observer.observe(document, {
subtree: true,
attributes: true
//...
});
thanks to @apsillers for useful trick in the following thread: Is there a JavaScript / jQuery DOM change listener?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…