diff --git a/src/content/index.js b/src/content/index.js index c2caa28..0fe4f36 100644 --- a/src/content/index.js +++ b/src/content/index.js @@ -20,13 +20,19 @@ init(); let prevSelectedText = ""; const handleMouseUp = async e => { await waitTime(10); + const isLeftClick = e.button === 0; + if (!isLeftClick) return; + const isInPasswordField = e.target.tagName === "INPUT" && e.target.type === "password"; + if (isInPasswordField) return; + + const inCodeElement = e.target.tagName === 'CODE' || !!e.target.closest('code') + if (inCodeElement) return; + const isInThisElement = document.querySelector("#simple-translate") && document.querySelector("#simple-translate").contains(e.target); - if (!isLeftClick) return; - if (isInPasswordField) return; if (isInThisElement) return; removeTranslatecontainer();