diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-10-11 22:35:59 -0400 |
---|---|---|
committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-10-11 23:24:51 -0400 |
commit | cc72514ce6260bc489b8dd9b51ea27b9fb6e3ce8 (patch) | |
tree | 2c233ad490183780f9812994f5b1345dd1adff98 /ext/fg/js/frontend.js | |
parent | a6903d68a409544f0f26f4cefb2ad6c40f9994c9 (diff) |
Frontend updates
Diffstat (limited to 'ext/fg/js/frontend.js')
-rw-r--r-- | ext/fg/js/frontend.js | 15 |
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(); |