aboutsummaryrefslogtreecommitdiff
path: root/ext/js/background/backend.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/background/backend.js')
-rw-r--r--ext/js/background/backend.js16
1 files changed, 14 insertions, 2 deletions
diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js
index dea67091..8e05ee68 100644
--- a/ext/js/background/backend.js
+++ b/ext/js/background/backend.js
@@ -31,6 +31,7 @@
* PermissionsUtil
* ProfileConditionsUtil
* RequestBuilder
+ * StringUtil
* Translator
* wanakana
*/
@@ -621,7 +622,7 @@ class Backend {
}
async _onApiGetMedia({targets}) {
- return await this._dictionaryDatabase.getMedia(targets);
+ return await this._getNormalizedDictionaryDatabaseMedia(targets);
}
_onApiLog({error, level, context}) {
@@ -1847,7 +1848,7 @@ class Backend {
detailsList.push(details);
detailsMap.set(key, details);
}
- const mediaList = await this._dictionaryDatabase.getMedia(targets);
+ const mediaList = await this._getNormalizedDictionaryDatabaseMedia(targets);
for (const media of mediaList) {
const {dictionary, path} = media;
@@ -2283,4 +2284,15 @@ class Backend {
return await this._injectScript(file, tab.id, frameId);
}
+
+ async _getNormalizedDictionaryDatabaseMedia(targets) {
+ const results = await this._dictionaryDatabase.getMedia(targets);
+ for (const item of results) {
+ const {content} = item;
+ if (content instanceof ArrayBuffer) {
+ item.content = StringUtil.arrayBufferToBase64(content);
+ }
+ }
+ return results;
+ }
}