I am experiencing odd behavior on an extension.
It generates a context menu, and then fires depending on what menu is clicked.
If I use this in a text box, it will run once, returning “am I looping” to the console log once, but if I do this in a content editable html element it runs 3 times.
I have stripped down the content script to the minimum parts and run it, and I still get it running 3 times for a content editable html element.
Is this a bug, or am I missing something?
(function(global) {
var clickedElement = null;
document.removeEventListener("mousedown", function(event) {
//right click
if (event.button == 2) {
clickedElement = event.target;
}
}, true);
browser.runtime.onMessage.removeListener(function(commandString, sendResponse) {
CommandParse(commandString);
}, true);
document.addEventListener("mousedown", function(event) {
//right click
if (event.button == 2) {
clickedElement = event.target;
}
}, true);
browser.runtime.onMessage.addListener(function(commandString, sendResponse) {
CommandParse(commandString);
});
async function CommandParse(argString) {
console.log("am I looping");
}
}) (this);