summaryrefslogtreecommitdiff
path: root/ext/fg/js/frontend.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fg/js/frontend.js')
-rw-r--r--ext/fg/js/frontend.js15
1 files changed, 12 insertions, 3 deletions
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js
index 88cb93a9..1c41cad1 100644
--- a/ext/fg/js/frontend.js
+++ b/ext/fg/js/frontend.js
@@ -41,6 +41,9 @@ class Frontend {
this.enabled = false;
this.eventListeners = [];
+
+ this.isPreparedPromiseResolve = null;
+ this.isPreparedPromise = new Promise((resolve) => { this.isPreparedPromiseResolve = resolve; });
}
static create() {
@@ -59,11 +62,16 @@ class Frontend {
await this.updateOptions();
chrome.runtime.onMessage.addListener(this.onRuntimeMessage.bind(this));
+ this.isPreparedPromiseResolve();
} catch (e) {
this.onError(e);
}
}
+ isPrepared() {
+ return this.isPreparedPromise;
+ }
+
onMouseOver(e) {
if (e.target === this.popup.container && this.popupTimer !== null) {
this.popupTimerClear();
@@ -303,6 +311,10 @@ class Frontend {
}
const textSource = docRangeFromPoint(x, y, this.options);
+ return await this.searchSource(textSource, cause);
+ }
+
+ async searchSource(textSource, cause) {
let hideResults = textSource === null;
let searched = false;
let success = false;
@@ -560,6 +572,3 @@ Frontend.runtimeMessageHandlers = {
self.popup.setVisibleOverride(visible);
}
};
-
-
-window.yomichan_frontend = Frontend.create();