I am using selectionchange to capture the user select in google chrome extension content script like this:
document.addEventListener(TransGlobal.SELECTION_CHANGE, fireSelection);
export async function fireSelection(e: MouseEvent) {
if (selection && selection.toString().trim().length > 0) {
// do some select logic
}
}
I found when double click the web element and do some selection, the fireSelection
triggered twice, two of the trigger both have selection content but the selection content be the same. why did this happen? what should I do to make it only triggered once?