summaryrefslogtreecommitdiff
path: root/ext/fg/js/frontend-initialize.js
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2020-04-10 03:55:25 +0300
committersiikamiika <siikamiika@users.noreply.github.com>2020-04-11 21:01:27 +0300
commit92109bb5d25db99033b0bb9f7f3806883f79218d (patch)
tree999207ff066194323781d9d7c8d6e5d8364fb4e0 /ext/fg/js/frontend-initialize.js
parent1df59d57b5dcbf9d3efedcb21a4d5e16524a67c1 (diff)
allow disabling scan on search page live
Diffstat (limited to 'ext/fg/js/frontend-initialize.js')
-rw-r--r--ext/fg/js/frontend-initialize.js15
1 files changed, 13 insertions, 2 deletions
diff --git a/ext/fg/js/frontend-initialize.js b/ext/fg/js/frontend-initialize.js
index 5af7fdf0..3fe5ac5b 100644
--- a/ext/fg/js/frontend-initialize.js
+++ b/ext/fg/js/frontend-initialize.js
@@ -28,7 +28,18 @@ async function main() {
await yomichan.prepare();
const data = window.frontendInitializationData || {};
- const {id, depth=0, parentFrameId, url, proxy=false} = data;
+ const {id, depth=0, parentFrameId, url, proxy=false, isSearchPage=false} = data;
+
+ const initEventDispatcher = new EventDispatcher();
+
+ yomichan.on('optionsUpdated', async () => {
+ const optionsContext = {depth: isSearchPage ? 0 : depth, url};
+ const options = await apiOptionsGet(optionsContext);
+ if (isSearchPage) {
+ const disabled = !options.scanning.enableOnSearchPage;
+ initEventDispatcher.trigger('setDisabledOverride', {disabled});
+ }
+ });
const optionsContext = {depth, url};
const options = await apiOptionsGet(optionsContext);
@@ -65,7 +76,7 @@ async function main() {
popup = popupHost.getOrCreatePopup(null, null, depth);
}
- const frontend = new Frontend(popup);
+ const frontend = new Frontend(popup, initEventDispatcher);
await frontend.prepare();
}