aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/yomichan.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js/yomichan.js')
-rw-r--r--ext/bg/js/yomichan.js35
1 files changed, 13 insertions, 22 deletions
diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js
index 3a42c594..50a8a636 100644
--- a/ext/bg/js/yomichan.js
+++ b/ext/bg/js/yomichan.js
@@ -56,7 +56,10 @@ window.yomichan = new class {
}
noteFormat(definition, mode) {
- const note = {fields: {}, tags: this.options.anki.tags};
+ const note = {
+ fields: {},
+ tags: this.options.anki.tags
+ };
let fields = [];
if (mode === 'kanji') {
@@ -67,25 +70,6 @@ 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) {
@@ -117,8 +101,15 @@ window.yomichan = new class {
}
definitionAdd(definition, mode) {
- const note = this.noteFormat(definition, mode);
- return this.anki.addNote(note);
+ let promise = Promise.resolve();
+ if (this.options.general.audioPlayback && mode !== 'kanji') {
+ promise = audioInject(definition, this.options.anki.terms.fields);
+ }
+
+ return promise.then(() => {
+ const note = this.noteFormat(definition, mode);
+ return this.anki.addNote(note);
+ });
}
definitionsAddable(definitions, modes) {