aboutsummaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-12-21 13:19:31 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-12-21 13:19:31 -0500
commit7ae05840772c04f1263f851432e21bd5a313b320 (patch)
treed72cce74cf32a774e7ac0ed2bd717b594c24f2a9 /ext
parent35216332bff4f654ce5ab3952369c012e2565fd9 (diff)
Update initialization
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/js/settings/popup-preview-frame.js9
-rw-r--r--ext/fg/js/frontend-initialize.js11
-rw-r--r--ext/fg/js/frontend.js18
3 files changed, 15 insertions, 23 deletions
diff --git a/ext/bg/js/settings/popup-preview-frame.js b/ext/bg/js/settings/popup-preview-frame.js
index cabadced..53077a83 100644
--- a/ext/bg/js/settings/popup-preview-frame.js
+++ b/ext/bg/js/settings/popup-preview-frame.js
@@ -47,14 +47,15 @@ class SettingsPopupPreview {
window.apiOptionsGet = (...args) => this.apiOptionsGet(...args);
// Overwrite frontend
- this.frontend = Frontend.create();
+ const popup = PopupProxyHost.instance.createPopup(null, 0);
+ popup.setChildrenSupported(false);
+
+ this.frontend = new Frontend(popup);
this.frontend.setEnabled = function () {};
this.frontend.searchClear = function () {};
- this.frontend.popup.setChildrenSupported(false);
-
- await this.frontend.isPrepared();
+ await this.frontend.prepare();
// Overwrite popup
Popup.injectOuterStylesheet = (...args) => this.popupInjectOuterStylesheet(...args);
diff --git a/ext/fg/js/frontend-initialize.js b/ext/fg/js/frontend-initialize.js
index 8ffdf528..4fef3a2e 100644
--- a/ext/fg/js/frontend-initialize.js
+++ b/ext/fg/js/frontend-initialize.js
@@ -17,4 +17,13 @@
*/
-Frontend.create();
+async function main() {
+ const data = window.frontendInitializationData || {};
+ const {id, depth=0, parentFrameId, ignoreNodes, url, proxy=false} = data;
+
+ const popup = proxy ? new PopupProxy(depth + 1, id, parentFrameId, url) : PopupProxyHost.instance.createPopup(null, depth);
+ const frontend = new Frontend(popup, ignoreNodes);
+ await frontend.prepare();
+}
+
+main();
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js
index 6b41138f..6239a057 100644
--- a/ext/fg/js/frontend.js
+++ b/ext/fg/js/frontend.js
@@ -34,23 +34,10 @@ class Frontend extends TextScanner {
url: popup.url
};
- this.isPreparedPromiseResolve = null;
- this.isPreparedPromise = new Promise((resolve) => { this.isPreparedPromiseResolve = resolve; });
-
this._orphaned = true;
this._lastShowPromise = Promise.resolve();
}
- static create() {
- const data = window.frontendInitializationData || {};
- const {id, depth=0, parentFrameId, ignoreNodes, url, proxy=false} = data;
-
- const popup = proxy ? new PopupProxy(depth + 1, id, parentFrameId, url) : PopupProxyHost.instance.createPopup(null, depth);
- const frontend = new Frontend(popup, ignoreNodes);
- frontend.prepare();
- return frontend;
- }
-
async prepare() {
try {
await this.updateOptions();
@@ -58,16 +45,11 @@ class Frontend extends TextScanner {
yomichan.on('orphaned', () => this.onOrphaned());
yomichan.on('optionsUpdate', () => this.updateOptions());
chrome.runtime.onMessage.addListener(this.onRuntimeMessage.bind(this));
- this.isPreparedPromiseResolve();
} catch (e) {
this.onError(e);
}
}
- isPrepared() {
- return this.isPreparedPromise;
- }
-
async onResize() {
const textSource = this.textSourceCurrent;
if (textSource !== null && await this.popup.isVisible()) {