From 83a6c30d0e68496bc7592b3adfa91ae536a487e1 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sat, 25 Mar 2017 12:01:20 -0700 Subject: audio improvements --- ext/bg/js/yomichan.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'ext/bg') diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js index 50a8a636..e2deb2cd 100644 --- a/ext/bg/js/yomichan.js +++ b/ext/bg/js/yomichan.js @@ -70,6 +70,25 @@ window.yomichan = new class { fields = this.options.anki.terms.fields; note.deckName = this.options.anki.terms.deck; note.modelName = this.options.anki.terms.model; + + if (definition.audio) { + const audio = { + url: definition.audio.url, + filename: definition.audio.filename, + skipHash: '7e2c2f954ef6051373ba916f000168dc', + fields: [] + }; + + for (const name in fields) { + if (fields[name].includes('{audio}')) { + audio.fields.push(name); + } + } + + if (audio.fields.length > 0) { + note.audio = audio; + } + } } for (const name in fields) { @@ -102,7 +121,7 @@ window.yomichan = new class { definitionAdd(definition, mode) { let promise = Promise.resolve(); - if (this.options.general.audioPlayback && mode !== 'kanji') { + if (mode !== 'kanji') { promise = audioInject(definition, this.options.anki.terms.fields); } -- cgit v1.2.3