From 92109bb5d25db99033b0bb9f7f3806883f79218d Mon Sep 17 00:00:00 2001 From: siikamiika Date: Fri, 10 Apr 2020 03:55:25 +0300 Subject: allow disabling scan on search page live --- ext/fg/js/frontend-initialize.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'ext/fg/js/frontend-initialize.js') 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(); } -- cgit v1.2.3