Reputation: 1
i code an chrome extension and I need that on any site, when you click on any element, no action occurs on them, but they are painted over in a certain color
I first used preventDefault, then added stopPropagation and stopImmediatePropogation and it didn’t work. Rather it doesn't work on some elements, that is, when clicked, it goes to another page.
document.querySelectorAll('*').forEach(elem => {
elem.addEventListener('click', this.mouseclickBind);
});
document.addEventListener('click', this.mouseclickBind);
mouseclickFunc(event) {
event.stopPropagation();
event.stopImmediatePropagation();
event.preventDefault();
let elem = event.target;
if (elem && this.illegalTags.indexOf(elem.tagName)) {
if (elem.dataset.mark === this.mark_train) {
delete elem.dataset.mark;
this.selectedElems.pop(elem);
} else {
elem.dataset.mark = this.mark_train;
this.selectedElems.push(elem);
}
}
}
why does it happen? and how do I solve it?
Upvotes: 0
Views: 73