From f3fe0994f52067d7c6d1886b02afd8f0a2a15099 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Wed, 8 Feb 2017 09:24:14 -0800 Subject: [PATCH] add option to disable imposters, bump version --- ext/bg/js/options-form.js | 2 ++ ext/bg/js/options.js | 1 + ext/bg/options.html | 4 ++++ ext/fg/js/driver.js | 2 +- ext/fg/js/util.js | 4 ++-- ext/manifest.json | 2 +- 6 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ext/bg/js/options-form.js b/ext/bg/js/options-form.js index 00b6a63e..4470d105 100644 --- a/ext/bg/js/options-form.js +++ b/ext/bg/js/options-form.js @@ -37,6 +37,7 @@ function getFormData() { optionsNew.scanning.requireShift = $('#hold-shift-to-scan').prop('checked'); optionsNew.scanning.selectText = $('#select-matched-text').prop('checked'); + optionsNew.scanning.imposter = $('#search-form-text-fields').prop('checked'); optionsNew.scanning.delay = parseInt($('#scan-delay').val(), 10); optionsNew.scanning.length = parseInt($('#scan-length').val(), 10); @@ -95,6 +96,7 @@ $(document).ready(() => { $('#hold-shift-to-scan').prop('checked', options.scanning.requireShift); $('#select-matched-text').prop('checked', options.scanning.selectText); + $('#search-form-text-fields').prop('checked', options.scanning.imposter); $('#scan-delay').val(options.scanning.delay); $('#scan-length').val(options.scanning.length); diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js index a4e39e41..65712c12 100644 --- a/ext/bg/js/options.js +++ b/ext/bg/js/options.js @@ -31,6 +31,7 @@ function optionsSetDefaults(options) { scanning: { requireShift: true, selectText: true, + imposter: true, delay: 15, length: 10 }, diff --git a/ext/bg/options.html b/ext/bg/options.html index d9d23c6a..ebb12f15 100644 --- a/ext/bg/options.html +++ b/ext/bg/options.html @@ -62,6 +62,10 @@ +
+ +
+
diff --git a/ext/fg/js/driver.js b/ext/fg/js/driver.js index 97f29f89..7facda0a 100644 --- a/ext/fg/js/driver.js +++ b/ext/fg/js/driver.js @@ -103,7 +103,7 @@ class Driver { return; } - const textSource = textSourceFromPoint(point); + const textSource = textSourceFromPoint(point, this.options.scanning.imposter); if (textSource === null || !textSource.containsPoint(point)) { if (hideNotFound) { this.searchClear(); diff --git a/ext/fg/js/util.js b/ext/fg/js/util.js index a7533846..641b73ac 100644 --- a/ext/fg/js/util.js +++ b/ext/fg/js/util.js @@ -93,12 +93,12 @@ function destroyImposters() { } } -function textSourceFromPoint(point) { +function textSourceFromPoint(point, imposter) { const element = document.elementFromPoint(point.x, point.y); if (element !== null) { if (element.nodeName === 'IMG' || element.nodeName === 'BUTTON') { return new TextSourceElement(element); - } else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') { + } else if (imposter && (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA')) { createImposter(element); } } diff --git a/ext/manifest.json b/ext/manifest.json index ba7e36e6..83651a62 100644 --- a/ext/manifest.json +++ b/ext/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Yomichan", - "version": "1.0.10", + "version": "1.0.11", "description": "Japanese dictionary with Anki integration", "icons": {"16": "img/icon16.png", "48": "img/icon48.png", "128": "img/icon128.png"},