Add option for enabling deep scanning
This commit is contained in:
parent
737a5ee8a8
commit
171e3f1097
@ -218,7 +218,8 @@ function optionsSetDefaults(options) {
|
|||||||
autoHideResults: false,
|
autoHideResults: false,
|
||||||
delay: 20,
|
delay: 20,
|
||||||
length: 10,
|
length: 10,
|
||||||
modifier: 'shift'
|
modifier: 'shift',
|
||||||
|
deepDomScan: false
|
||||||
},
|
},
|
||||||
|
|
||||||
dictionaries: {},
|
dictionaries: {},
|
||||||
|
@ -47,6 +47,7 @@ async function formRead() {
|
|||||||
optionsNew.scanning.selectText = $('#select-matched-text').prop('checked');
|
optionsNew.scanning.selectText = $('#select-matched-text').prop('checked');
|
||||||
optionsNew.scanning.alphanumeric = $('#search-alphanumeric').prop('checked');
|
optionsNew.scanning.alphanumeric = $('#search-alphanumeric').prop('checked');
|
||||||
optionsNew.scanning.autoHideResults = $('#auto-hide-results').prop('checked');
|
optionsNew.scanning.autoHideResults = $('#auto-hide-results').prop('checked');
|
||||||
|
optionsNew.scanning.deepDomScan = $('#deep-dom-scan').prop('checked');
|
||||||
optionsNew.scanning.delay = parseInt($('#scan-delay').val(), 10);
|
optionsNew.scanning.delay = parseInt($('#scan-delay').val(), 10);
|
||||||
optionsNew.scanning.length = parseInt($('#scan-length').val(), 10);
|
optionsNew.scanning.length = parseInt($('#scan-length').val(), 10);
|
||||||
optionsNew.scanning.modifier = $('#scan-modifier-key').val();
|
optionsNew.scanning.modifier = $('#scan-modifier-key').val();
|
||||||
@ -187,6 +188,7 @@ async function onReady() {
|
|||||||
$('#select-matched-text').prop('checked', options.scanning.selectText);
|
$('#select-matched-text').prop('checked', options.scanning.selectText);
|
||||||
$('#search-alphanumeric').prop('checked', options.scanning.alphanumeric);
|
$('#search-alphanumeric').prop('checked', options.scanning.alphanumeric);
|
||||||
$('#auto-hide-results').prop('checked', options.scanning.autoHideResults);
|
$('#auto-hide-results').prop('checked', options.scanning.autoHideResults);
|
||||||
|
$('#deep-dom-scan').prop('checked', options.scanning.deepDomScan);
|
||||||
$('#scan-delay').val(options.scanning.delay);
|
$('#scan-delay').val(options.scanning.delay);
|
||||||
$('#scan-length').val(options.scanning.length);
|
$('#scan-length').val(options.scanning.length);
|
||||||
$('#scan-modifier-key').val(options.scanning.modifier);
|
$('#scan-modifier-key').val(options.scanning.modifier);
|
||||||
|
@ -192,6 +192,10 @@
|
|||||||
<label><input type="checkbox" id="auto-hide-results"> Automatically hide results</label>
|
<label><input type="checkbox" id="auto-hide-results"> Automatically hide results</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="checkbox options-advanced">
|
||||||
|
<label><input type="checkbox" id="deep-dom-scan"> Deep DOM scan</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group options-advanced">
|
<div class="form-group options-advanced">
|
||||||
<label for="scan-delay">Scan delay (in milliseconds)</label>
|
<label for="scan-delay">Scan delay (in milliseconds)</label>
|
||||||
<input type="number" min="1" id="scan-delay" class="form-control">
|
<input type="number" min="1" id="scan-delay" class="form-control">
|
||||||
|
@ -89,7 +89,7 @@ function docImposterCreate(element, isTextarea) {
|
|||||||
return [imposter, container];
|
return [imposter, container];
|
||||||
}
|
}
|
||||||
|
|
||||||
function docRangeFromPoint({x, y}) {
|
function docRangeFromPoint({x, y}, options) {
|
||||||
const elements = document.elementsFromPoint(x, y);
|
const elements = document.elementsFromPoint(x, y);
|
||||||
let imposter = null;
|
let imposter = null;
|
||||||
let imposterContainer = null;
|
let imposterContainer = null;
|
||||||
@ -108,7 +108,7 @@ function docRangeFromPoint({x, y}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const range = caretRangeFromPointExt(x, y, elements);
|
const range = caretRangeFromPointExt(x, y, options.scanning.deepDomScan ? elements : []);
|
||||||
if (range !== null) {
|
if (range !== null) {
|
||||||
if (imposter !== null) {
|
if (imposter !== null) {
|
||||||
docSetImposterStyle(imposterContainer.style, 'z-index', '-2147483646');
|
docSetImposterStyle(imposterContainer.style, 'z-index', '-2147483646');
|
||||||
|
@ -285,7 +285,7 @@ class Frontend {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const textSource = docRangeFromPoint(point);
|
const textSource = docRangeFromPoint(point, this.options);
|
||||||
let hideResults = !textSource || !textSource.containsPoint(point);
|
let hideResults = !textSource || !textSource.containsPoint(point);
|
||||||
let searched = false;
|
let searched = false;
|
||||||
let success = false;
|
let success = false;
|
||||||
|
@ -80,7 +80,7 @@ class Display {
|
|||||||
const {docRangeFromPoint, docSentenceExtract} = this.dependencies;
|
const {docRangeFromPoint, docSentenceExtract} = this.dependencies;
|
||||||
|
|
||||||
const clickedElement = $(e.target);
|
const clickedElement = $(e.target);
|
||||||
const textSource = docRangeFromPoint({x: e.clientX, y: e.clientY});
|
const textSource = docRangeFromPoint({x: e.clientX, y: e.clientY}, this.options);
|
||||||
if (textSource === null) {
|
if (textSource === null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user