Ignore <code> tag (#266)
* refactor: Getting out early will speed things up * feat: Ignore <code> tags
This commit is contained in:
parent
21f16c00af
commit
a1ffd7a44a
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue