fix search for input controls
This commit is contained in:
parent
fd346ae44b
commit
48693fa594
@ -144,6 +144,7 @@ window.driver = new class {
|
|||||||
|
|
||||||
const textSource = docRangeFromPoint(point, this.options.scanning.imposter);
|
const textSource = docRangeFromPoint(point, this.options.scanning.imposter);
|
||||||
if (!textSource || !textSource.containsPoint(point)) {
|
if (!textSource || !textSource.containsPoint(point)) {
|
||||||
|
docImposterDestroy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,6 +169,7 @@ window.driver = new class {
|
|||||||
|
|
||||||
return bgTermsFind(textSource.text()).then(({definitions, length}) => {
|
return bgTermsFind(textSource.text()).then(({definitions, length}) => {
|
||||||
if (definitions.length === 0) {
|
if (definitions.length === 0) {
|
||||||
|
docImposterDestroy();
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
textSource.setEndOffset(length);
|
textSource.setEndOffset(length);
|
||||||
@ -186,6 +188,7 @@ window.driver = new class {
|
|||||||
textSource.select();
|
textSource.select();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
docImposterDestroy();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -112,12 +112,6 @@ function docImposterDestroy() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function docImposterHide() {
|
|
||||||
for (const element of document.getElementsByClassName('yomichan-imposter')) {
|
|
||||||
element.style.visibility = 'hidden';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function docRangeFromPoint(point, imposter) {
|
function docRangeFromPoint(point, imposter) {
|
||||||
const element = document.elementFromPoint(point.x, point.y);
|
const element = document.elementFromPoint(point.x, point.y);
|
||||||
if (element !== null) {
|
if (element !== null) {
|
||||||
@ -144,11 +138,9 @@ function docRangeFromPoint(point, imposter) {
|
|||||||
|
|
||||||
const range = document.caretRangeFromPoint(point.x, point.y);
|
const range = document.caretRangeFromPoint(point.x, point.y);
|
||||||
if (range !== null) {
|
if (range !== null) {
|
||||||
docImposterHide();
|
|
||||||
return new TextSourceRange(range);
|
return new TextSourceRange(range);
|
||||||
}
|
}
|
||||||
|
|
||||||
docImposterDestroy();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user