summaryrefslogtreecommitdiff
path: root/ext/js/pages
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/pages')
-rw-r--r--ext/js/pages/action-popup-main.js9
-rw-r--r--ext/js/pages/settings/audio-controller.js4
-rw-r--r--ext/js/pages/settings/settings-main.js27
3 files changed, 32 insertions, 8 deletions
diff --git a/ext/js/pages/action-popup-main.js b/ext/js/pages/action-popup-main.js
index 2de986da..4934802b 100644
--- a/ext/js/pages/action-popup-main.js
+++ b/ext/js/pages/action-popup-main.js
@@ -103,6 +103,10 @@ class DisplayController {
let tab;
try {
tab = await this._getCurrentTab();
+ // Safari assigns a tab object to the popup, other browsers do not
+ if (tab && await this._isSafari()) {
+ tab = void 0;
+ }
} catch (e) {
// NOP
}
@@ -220,6 +224,11 @@ class DisplayController {
node.hidden = false;
}
}
+
+ async _isSafari() {
+ const {browser} = await yomichan.api.getEnvironmentInfo();
+ return browser === 'safari';
+ }
}
(async () => {
diff --git a/ext/js/pages/settings/audio-controller.js b/ext/js/pages/settings/audio-controller.js
index e62383a8..6b1ce0b5 100644
--- a/ext/js/pages/settings/audio-controller.js
+++ b/ext/js/pages/settings/audio-controller.js
@@ -39,9 +39,7 @@ class AudioController {
this._audioSourceAddButton.addEventListener('click', this._onAddAudioSource.bind(this), false);
- if (typeof speechSynthesis !== 'undefined') {
- speechSynthesis.addEventListener('voiceschanged', this._updateTextToSpeechVoices.bind(this), false);
- }
+ this._audioSystem.on('voiceschanged', this._updateTextToSpeechVoices.bind(this), false);
this._updateTextToSpeechVoices();
document.querySelector('#text-to-speech-voice-test').addEventListener('click', this._onTestTextToSpeech.bind(this), false);
diff --git a/ext/js/pages/settings/settings-main.js b/ext/js/pages/settings/settings-main.js
index 2560685c..6f3e2a58 100644
--- a/ext/js/pages/settings/settings-main.js
+++ b/ext/js/pages/settings/settings-main.js
@@ -24,6 +24,7 @@
* DictionaryController
* DictionaryImportController
* DocumentFocusController
+ * Environment
* ExtensionKeyboardShortcutController
* GenericSettingController
* KeyboardShortcutController
@@ -47,11 +48,16 @@
*/
async function setupEnvironmentInfo() {
+ const {dataset} = document.documentElement;
const {manifest_version: manifestVersion} = chrome.runtime.getManifest();
- const {browser, platform} = await yomichan.api.getEnvironmentInfo();
- document.documentElement.dataset.browser = browser;
- document.documentElement.dataset.os = platform.os;
- document.documentElement.dataset.manifestVersion = `${manifestVersion}`;
+ dataset.manifestVersion = `${manifestVersion}`;
+
+ const environment = new Environment();
+ await environment.prepare();
+ const {browser, platform} = environment.getInfo();
+
+ dataset.browser = browser;
+ dataset.os = platform.os;
}
async function setupGenericSettingsController(genericSettingController) {
@@ -67,9 +73,20 @@ async function setupGenericSettingsController(genericSettingController) {
const statusFooter = new StatusFooter(document.querySelector('.status-footer-container'));
statusFooter.prepare();
+ setupEnvironmentInfo();
+
+ let prepareTimer = setTimeout(() => {
+ prepareTimer = null;
+ document.documentElement.dataset.loadingStalled = 'true';
+ }, 1000);
+
await yomichan.prepare();
- setupEnvironmentInfo();
+ if (prepareTimer !== null) {
+ clearTimeout(prepareTimer);
+ prepareTimer = null;
+ }
+ delete document.documentElement.dataset.loadingStalled;
const optionsFull = await yomichan.api.optionsGetFull();