From c12844c52c9b2d6bc1469a317614a2ec1460070c Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sat, 6 May 2017 12:17:19 -0700 Subject: [PATCH 01/19] Updating README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5b1e9182..f342564a 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ Flashcard fields can be configured with the following steps: 2. Tick the checkbox labeled *Enable Anki integration* (Anki must be running with [AnkiConnect](https://foosoft.net/projects/anki-connect) installed). 3. Select the type of template to configure by clicking on either the *Terms* or *Kanji* tabs. 4. Select the Anki deck and model to use for new creating new flashcards of this type. -5. Fill out the displayed model fields with markers representing the information you wish to include: +5. Fill the model fields with markers corresponding to the information you wish to include (several can be used): #### Markers for Term Cards #### From 89f6cb3074038c8c54b7e85c19dff1161f3ad3ae Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sat, 6 May 2017 12:18:02 -0700 Subject: [PATCH 02/19] Updating README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5b1e9182..f342564a 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ Flashcard fields can be configured with the following steps: 2. Tick the checkbox labeled *Enable Anki integration* (Anki must be running with [AnkiConnect](https://foosoft.net/projects/anki-connect) installed). 3. Select the type of template to configure by clicking on either the *Terms* or *Kanji* tabs. 4. Select the Anki deck and model to use for new creating new flashcards of this type. -5. Fill out the displayed model fields with markers representing the information you wish to include: +5. Fill the model fields with markers corresponding to the information you wish to include (several can be used): #### Markers for Term Cards #### From b04c4d8be79a476bf408eb3ad74648baf7ba8cf5 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sat, 20 May 2017 18:15:51 -0700 Subject: [PATCH 03/19] block RT and some other tags when scanning, fixes #50, #30 --- ext/fg/js/source-range.js | 54 ++++++++++++++++++++++++--------------- ext/manifest.json | 2 +- 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/ext/fg/js/source-range.js b/ext/fg/js/source-range.js index 6d445f54..5db0ffc7 100644 --- a/ext/fg/js/source-range.js +++ b/ext/fg/js/source-range.js @@ -20,27 +20,30 @@ class TextSourceRange { constructor(range) { this.rng = range; + this.content = ''; } clone() { - return new TextSourceRange(this.rng.cloneRange()); + const tmp = new TextSourceRange(this.rng.cloneRange()); + tmp.content = this.content; + return tmp; } text() { - return this.rng.toString(); + return this.content; } setEndOffset(length) { - const lengthAdj = length + this.rng.startOffset; - const state = TextSourceRange.seekForward(this.rng.startContainer, lengthAdj); + const state = TextSourceRange.seekForward(this.rng.startContainer, this.rng.startOffset, length); this.rng.setEnd(state.node, state.offset); + this.content = state.content; return length - state.length; } setStartOffset(length) { - const lengthAdj = length + (this.rng.startContainer.length - this.rng.startOffset); - const state = TextSourceRange.seekBackward(this.rng.startContainer, lengthAdj); + const state = TextSourceRange.seekBackward(this.rng.startContainer, this.rng.startOffset, length); this.rng.setStart(state.node, state.offset); + this.content = state.content; return length - state.length; } @@ -80,8 +83,13 @@ class TextSourceRange { return other.rng && other.rng.compareBoundaryPoints(Range.START_TO_START, this.rng) === 0; } - static seekForward(node, length) { - const state = {node, length, offset: 0}; + static shouldEnter(node) { + const skip = ['RT', 'SCRIPT', 'STYLE']; + return !skip.includes(node.nodeName); + } + + static seekForward(node, offset, length) { + const state = {node, offset, remainder: length, content: ''}; if (!TextSourceRange.seekForwardHelper(node, state)) { return state; } @@ -99,11 +107,14 @@ class TextSourceRange { static seekForwardHelper(node, state) { if (node.nodeType === 3) { - const consumed = Math.min(node.length, state.length); + const offset = state.node === node ? state.offset : 0; + const remaining = node.length - offset; + const consumed = Math.min(remaining, state.remainder); + state.content = state.content + node.nodeValue.substring(offset, offset + consumed); state.node = node; - state.offset = consumed; - state.length -= consumed; - } else { + state.offset = offset + consumed; + state.remainder -= consumed; + } else if (TextSourceRange.shouldEnter(node)) { for (let i = 0; i < node.childNodes.length; ++i) { if (!TextSourceRange.seekForwardHelper(node.childNodes[i], state)) { break; @@ -111,11 +122,11 @@ class TextSourceRange { } } - return state.length > 0; + return state.remainder > 0; } - static seekBackward(node, length) { - const state = {node, length, offset: node.length}; + static seekBackward(node, offset, length) { + const state = {node, offset, remainder: length, content: ''}; if (!TextSourceRange.seekBackwardHelper(node, state)) { return state; } @@ -133,11 +144,14 @@ class TextSourceRange { static seekBackwardHelper(node, state) { if (node.nodeType === 3) { - const consumed = Math.min(node.length, state.length); + const offset = state.node === node ? state.offset : node.length; + const remaining = offset; + const consumed = Math.min(remaining, state.remainder); + state.content = node.nodeValue.substring(offset - consumed, offset) + state.content; state.node = node; - state.offset = node.length - consumed; - state.length -= consumed; - } else { + state.offset = offset - consumed; + state.remainder -= consumed; + } else if (TextSourceRange.shouldEnter(node)) { for (let i = node.childNodes.length - 1; i >= 0; --i) { if (!TextSourceRange.seekBackwardHelper(node.childNodes[i], state)) { break; @@ -145,6 +159,6 @@ class TextSourceRange { } } - return state.length > 0; + return state.remainder > 0; } } diff --git a/ext/manifest.json b/ext/manifest.json index c78c0935..c56c8b0c 100644 --- a/ext/manifest.json +++ b/ext/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Yomichan", - "version": "1.1.15", + "version": "1.1.16", "description": "Japanese dictionary with Anki integration", "icons": {"16": "mixed/img/icon16.png", "48": "mixed/img/icon48.png", "128": "mixed/img/icon128.png"}, From 52f092f0d2709e4fb8b1c00a4aea1fba97920509 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sat, 20 May 2017 18:34:13 -0700 Subject: [PATCH 04/19] fixing old variable name --- ext/fg/js/source-range.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/fg/js/source-range.js b/ext/fg/js/source-range.js index 5db0ffc7..58b6a415 100644 --- a/ext/fg/js/source-range.js +++ b/ext/fg/js/source-range.js @@ -37,14 +37,14 @@ class TextSourceRange { const state = TextSourceRange.seekForward(this.rng.startContainer, this.rng.startOffset, length); this.rng.setEnd(state.node, state.offset); this.content = state.content; - return length - state.length; + return length - state.remainder; } setStartOffset(length) { const state = TextSourceRange.seekBackward(this.rng.startContainer, this.rng.startOffset, length); this.rng.setStart(state.node, state.offset); this.content = state.content; - return length - state.length; + return length - state.remainder; } containsPoint(point) { From 48f612bb9235abfbedab9679c8238cbaaeab2a58 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sat, 20 May 2017 18:41:55 -0700 Subject: [PATCH 05/19] Updating README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f342564a..3265b4af 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Yomichan provides advanced features not available in other browser-based diction * **Mozilla Firefox** (versions 51+) * [Locally hosted](https://foosoft.net/projects/yomichan/dl/latest.xpi) *(recommended)*: Latest and greatest, released simultaneously with the Chrome version. * [Marketplace hosted](https://addons.mozilla.org/en-US/firefox/addon/yomichan/): Officially hosted version, - likely to be substantially out of date (queued for initial approval). + likely to be substantially out of date. ## Basic Features ## From 84f5954ad52e82b795b1e493a9111355ddaa0f07 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sun, 21 May 2017 22:44:22 -0700 Subject: [PATCH 06/19] handle scanning text for janky websites better #23 --- ext/fg/js/source-range.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/ext/fg/js/source-range.js b/ext/fg/js/source-range.js index 58b6a415..95177f0b 100644 --- a/ext/fg/js/source-range.js +++ b/ext/fg/js/source-range.js @@ -84,8 +84,22 @@ class TextSourceRange { } static shouldEnter(node) { + if (node.nodeType !== 1) { + return false; + } + const skip = ['RT', 'SCRIPT', 'STYLE']; - return !skip.includes(node.nodeName); + if (skip.includes(node.nodeName)) { + return false; + } + + const style = window.getComputedStyle(node); + const hidden = + style.visibility === 'hidden' || + style.display === 'none' || + parseFloat(style.fontSize) === 0; + + return !hidden; } static seekForward(node, offset, length) { @@ -106,7 +120,7 @@ class TextSourceRange { } static seekForwardHelper(node, state) { - if (node.nodeType === 3) { + if (node.nodeType === 3 && node.parentElement && TextSourceRange.shouldEnter(node.parentElement)) { const offset = state.node === node ? state.offset : 0; const remaining = node.length - offset; const consumed = Math.min(remaining, state.remainder); @@ -143,7 +157,7 @@ class TextSourceRange { } static seekBackwardHelper(node, state) { - if (node.nodeType === 3) { + if (node.nodeType === 3 && node.parentElement && TextSourceRange.shouldEnter(node.parentElement)) { const offset = state.node === node ? state.offset : node.length; const remaining = offset; const consumed = Math.min(remaining, state.remainder); From c6673bdf481e7242a18b7fc4c32c6ec88be642f0 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sun, 21 May 2017 22:47:23 -0700 Subject: [PATCH 07/19] version bump --- ext/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/manifest.json b/ext/manifest.json index c56c8b0c..eac8c058 100644 --- a/ext/manifest.json +++ b/ext/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Yomichan", - "version": "1.1.16", + "version": "1.1.17", "description": "Japanese dictionary with Anki integration", "icons": {"16": "mixed/img/icon16.png", "48": "mixed/img/icon48.png", "128": "mixed/img/icon128.png"}, From fd346ae44b75afa2a081d3ce270568258dd8390b Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Mon, 22 May 2017 21:07:25 -0700 Subject: [PATCH 08/19] wip --- ext/fg/js/source-element.js | 49 +++++++++++++++++++------------------ ext/fg/js/source-range.js | 26 +++++++++----------- 2 files changed, 37 insertions(+), 38 deletions(-) diff --git a/ext/fg/js/source-element.js b/ext/fg/js/source-element.js index 69fbc5ab..a8101382 100644 --- a/ext/fg/js/source-element.js +++ b/ext/fg/js/source-element.js @@ -18,39 +18,40 @@ class TextSourceElement { - constructor(element, length=-1) { + constructor(element, content='') { this.element = element; - this.length = length; + this.content = content; } clone() { - return new TextSourceElement(this.element, this.length); + return new TextSourceElement(this.element, this.content); } text() { - const text = this.textRaw(); - return this.length < 0 ? text : text.substring(0, this.length); - } - - textRaw() { - switch (this.element.nodeName) { - case 'BUTTON': - return this.element.innerHTML; - case 'IMG': - return this.element.getAttribute('alt'); - default: - return this.element.value || ''; - } - } - - setStartOffset(length) { - // NOP - return 0; + return this.content; } setEndOffset(length) { - this.length = length; - return length; + switch (this.element.nodeName) { + case 'BUTTON': + this.content = this.element.innerHTML; + break; + case 'IMG': + this.content = this.element.getAttribute('alt'); + break; + default: + this.content = this.element.value; + break; + } + + this.content = this.content || ''; + this.content = this.content.substring(0, length); + + return this.content.length; + } + + setStartOffset(length) { + return 0; } containsPoint(point) { @@ -71,6 +72,6 @@ class TextSourceElement { } equals(other) { - return other.element && other.textRaw() === this.textRaw(); + return other.element === this.element && other.content === this.content; } } diff --git a/ext/fg/js/source-range.js b/ext/fg/js/source-range.js index 95177f0b..fa73b0a4 100644 --- a/ext/fg/js/source-range.js +++ b/ext/fg/js/source-range.js @@ -18,15 +18,13 @@ class TextSourceRange { - constructor(range) { - this.rng = range; - this.content = ''; + constructor(range, content='') { + this.range = range; + this.content = content; } clone() { - const tmp = new TextSourceRange(this.rng.cloneRange()); - tmp.content = this.content; - return tmp; + return new TextSourceRange(this.range.cloneRange(), this.content); } text() { @@ -34,15 +32,15 @@ class TextSourceRange { } setEndOffset(length) { - const state = TextSourceRange.seekForward(this.rng.startContainer, this.rng.startOffset, length); - this.rng.setEnd(state.node, state.offset); + const state = TextSourceRange.seekForward(this.range.startContainer, this.range.startOffset, length); + this.range.setEnd(state.node, state.offset); this.content = state.content; return length - state.remainder; } setStartOffset(length) { - const state = TextSourceRange.seekBackward(this.rng.startContainer, this.rng.startOffset, length); - this.rng.setStart(state.node, state.offset); + const state = TextSourceRange.seekBackward(this.range.startContainer, this.range.startOffset, length); + this.range.setStart(state.node, state.offset); this.content = state.content; return length - state.remainder; } @@ -53,11 +51,11 @@ class TextSourceRange { } getRect() { - return this.rng.getBoundingClientRect(); + return this.range.getBoundingClientRect(); } getPaddedRect() { - const range = this.rng.cloneRange(); + const range = this.range.cloneRange(); const startOffset = range.startOffset; const endOffset = range.endOffset; const node = range.startContainer; @@ -71,7 +69,7 @@ class TextSourceRange { select() { const selection = window.getSelection(); selection.removeAllRanges(); - selection.addRange(this.rng); + selection.addRange(this.range); } deselect() { @@ -80,7 +78,7 @@ class TextSourceRange { } equals(other) { - return other.rng && other.rng.compareBoundaryPoints(Range.START_TO_START, this.rng) === 0; + return other.range && other.range.compareBoundaryPoints(Range.START_TO_START, this.range) === 0; } static shouldEnter(node) { From 48693fa5942b8dc908615f73f08ceac8937b8216 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Mon, 22 May 2017 22:27:09 -0700 Subject: [PATCH 09/19] fix search for input controls --- ext/fg/js/driver.js | 3 +++ ext/fg/js/util.js | 8 -------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/ext/fg/js/driver.js b/ext/fg/js/driver.js index e94a4ac2..98c50a02 100644 --- a/ext/fg/js/driver.js +++ b/ext/fg/js/driver.js @@ -144,6 +144,7 @@ window.driver = new class { const textSource = docRangeFromPoint(point, this.options.scanning.imposter); if (!textSource || !textSource.containsPoint(point)) { + docImposterDestroy(); return; } @@ -168,6 +169,7 @@ window.driver = new class { return bgTermsFind(textSource.text()).then(({definitions, length}) => { if (definitions.length === 0) { + docImposterDestroy(); return false; } else { textSource.setEndOffset(length); @@ -186,6 +188,7 @@ window.driver = new class { textSource.select(); } + docImposterDestroy(); return true; } }); diff --git a/ext/fg/js/util.js b/ext/fg/js/util.js index e5705ffd..88d160cc 100644 --- a/ext/fg/js/util.js +++ b/ext/fg/js/util.js @@ -112,12 +112,6 @@ function docImposterDestroy() { } } -function docImposterHide() { - for (const element of document.getElementsByClassName('yomichan-imposter')) { - element.style.visibility = 'hidden'; - } -} - function docRangeFromPoint(point, imposter) { const element = document.elementFromPoint(point.x, point.y); if (element !== null) { @@ -144,11 +138,9 @@ function docRangeFromPoint(point, imposter) { const range = document.caretRangeFromPoint(point.x, point.y); if (range !== null) { - docImposterHide(); return new TextSourceRange(range); } - docImposterDestroy(); return null; } From ac406bdbf0d4b275ed8d1c48e29d0cb69e4d1800 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Tue, 23 May 2017 20:54:03 -0700 Subject: [PATCH 10/19] add debug info checkbox --- ext/bg/js/options.js | 2 ++ ext/bg/js/util.js | 1 + ext/bg/options.html | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js index 1ea6ed68..1b675da2 100644 --- a/ext/bg/js/options.js +++ b/ext/bg/js/options.js @@ -30,6 +30,7 @@ function formRead() { optionsNew.general.audioVolume = $('#audio-playback-volume').val(); optionsNew.general.groupResults = $('#group-terms-results').prop('checked'); optionsNew.general.softKatakana = $('#soft-katakana-search').prop('checked'); + optionsNew.general.debugInfo = $('#show-debug-info').prop('checked'); optionsNew.general.showAdvanced = $('#show-advanced-options').prop('checked'); optionsNew.general.maxResults = parseInt($('#max-displayed-results').val(), 10); optionsNew.general.popupWidth = parseInt($('#popup-width').val(), 10); @@ -118,6 +119,7 @@ $(document).ready(() => { $('#audio-playback-volume').val(options.general.audioVolume); $('#group-terms-results').prop('checked', options.general.groupResults); $('#soft-katakana-search').prop('checked', options.general.softKatakana); + $('#show-debug-info').prop('checked', options.general.debugInfo); $('#show-advanced-options').prop('checked', options.general.showAdvanced); $('#max-displayed-results').val(options.general.maxResults); $('#popup-width').val(options.general.popupWidth); diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js index 09337c63..74e1f49e 100644 --- a/ext/bg/js/util.js +++ b/ext/bg/js/util.js @@ -99,6 +99,7 @@ function optionsSetDefaults(options) { audioVolume: 100, groupResults: true, softKatakana: true, + debugInfo: false, maxResults: 32, showAdvanced: false, popupWidth: 400, diff --git a/ext/bg/options.html b/ext/bg/options.html index c3799b61..97dcd736 100644 --- a/ext/bg/options.html +++ b/ext/bg/options.html @@ -41,6 +41,10 @@ +
+ +
+
- +
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index 0167c605..7982c69f 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -69,7 +69,8 @@ class Display { definitions, addable: options.anki.enable, grouped: options.general.groupResults, - playback: options.general.audioSource !== 'disabled' + playback: options.general.audioSource !== 'disabled', + debug: options.general.debugInfo }; if (context) { @@ -106,7 +107,8 @@ class Display { const params = { definitions, source: context && context.source, - addable: options.anki.enable + addable: options.anki.enable, + debug: options.general.debugInfo }; if (context) { diff --git a/tmpl/kanji.html b/tmpl/kanji.html index acd79036..a2f78aff 100644 --- a/tmpl/kanji.html +++ b/tmpl/kanji.html @@ -50,13 +50,17 @@
{{#multiLine}}{{glossary.[0]}}{{/multiLine}}
{{/if}} + + {{#if debug}} +
{{#dumpObject}}{{{.}}}{{/dumpObject}}
+ {{/if}} {{/inline}} {{#if definitions}} {{#each definitions}} {{#unless @first}}
{{/unless}} -{{> kanji addable=../addable source=../source root=../root}} +{{> kanji debug=../debug addable=../addable source=../source root=../root}} {{/each}} {{else}}

No results found.

diff --git a/tmpl/terms.html b/tmpl/terms.html index dc50efe2..80735974 100644 --- a/tmpl/terms.html +++ b/tmpl/terms.html @@ -59,13 +59,17 @@ {{> definition}} {{/if}} + + {{#if debug}} +
{{#dumpObject}}{{{.}}}{{/dumpObject}}
+ {{/if}} {{/inline}} {{#if definitions}} {{#each definitions}} {{#unless @first}}
{{/unless}} -{{> term grouped=../grouped addable=../addable playback=../playback}} +{{> term debug=../debug grouped=../grouped addable=../addable playback=../playback}} {{/each}} {{else}}

No results found.

From c0f74bbc8f6e8dde4f8e254d3f4b260b4209daaa Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Tue, 23 May 2017 22:51:48 -0700 Subject: [PATCH 12/19] smarter imposter hiding, version bump --- ext/fg/js/driver.js | 3 +-- ext/manifest.json | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ext/fg/js/driver.js b/ext/fg/js/driver.js index 98c50a02..e11b5014 100644 --- a/ext/fg/js/driver.js +++ b/ext/fg/js/driver.js @@ -160,6 +160,7 @@ window.driver = new class { }).catch(error => { this.handleError(error, textSource); }).then(() => { + docImposterDestroy(); this.pendingLookup = false; }); } @@ -169,7 +170,6 @@ window.driver = new class { return bgTermsFind(textSource.text()).then(({definitions, length}) => { if (definitions.length === 0) { - docImposterDestroy(); return false; } else { textSource.setEndOffset(length); @@ -188,7 +188,6 @@ window.driver = new class { textSource.select(); } - docImposterDestroy(); return true; } }); diff --git a/ext/manifest.json b/ext/manifest.json index eac8c058..8b6a9a02 100644 --- a/ext/manifest.json +++ b/ext/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Yomichan", - "version": "1.1.17", + "version": "1.1.18", "description": "Japanese dictionary with Anki integration", "icons": {"16": "mixed/img/icon16.png", "48": "mixed/img/icon48.png", "128": "mixed/img/icon128.png"}, From b2833891f9b5d0ceaebc26586b02120bacec68be Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Wed, 24 May 2017 19:03:45 -0700 Subject: [PATCH 13/19] fix incorrect deinflection --- ext/bg/lang/deinflect.json | 8 -------- 1 file changed, 8 deletions(-) diff --git a/ext/bg/lang/deinflect.json b/ext/bg/lang/deinflect.json index 532f8e62..7ee00b2f 100644 --- a/ext/bg/lang/deinflect.json +++ b/ext/bg/lang/deinflect.json @@ -959,14 +959,6 @@ "v5" ] }, - { - "kanaIn": "って", - "kanaOut": "く", - "rulesIn": [], - "rulesOut": [ - "v5" - ] - }, { "kanaIn": "って", "kanaOut": "つ", From 0efab9773d0cc6586eb4a1f271821795b6d07f5c Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Wed, 24 May 2017 19:13:56 -0700 Subject: [PATCH 14/19] options debugging code --- ext/bg/js/options.js | 9 +++++++++ ext/bg/js/util.js | 6 +++++- ext/bg/options.html | 3 +++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js index 1b675da2..4eafd9ef 100644 --- a/ext/bg/js/options.js +++ b/ext/bg/js/options.js @@ -86,6 +86,15 @@ function updateVisibility(options) { } else { advanced.hide(); } + + const debug = $('#debug'); + if (options.general.debugInfo) { + const text = JSON.stringify(options, null, 4); + debug.html(handlebarsEscape(text)); + debug.show(); + } else { + debug.hide(); + } } function onOptionsChanged(e) { diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js index 64c79ab5..593e7d03 100644 --- a/ext/bg/js/util.js +++ b/ext/bg/js/util.js @@ -504,9 +504,13 @@ function jsonLoadDb(indexUrl, indexLoaded, termsLoaded, kanjiLoaded) { * Helpers */ +function handlebarsEscape(text) { + return Handlebars.Utils.escapeExpression(text); +} + function handlebarsDumpObject(options) { const dump = JSON.stringify(options.fn(this), null, 4); - return Handlebars.Utils.escapeExpression(dump); + return handlebarsEscape(dump); } function handlebarsKanjiLinks(options) { diff --git a/ext/bg/options.html b/ext/bg/options.html index 434241e3..8281c317 100644 --- a/ext/bg/options.html +++ b/ext/bg/options.html @@ -8,6 +8,7 @@