From 9ca906ef900dacfd10a548757d8a2b842a549088 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 19 Apr 2020 14:29:29 -0400 Subject: Create float-main.js --- ext/fg/float.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'ext/fg/float.html') diff --git a/ext/fg/float.html b/ext/fg/float.html index c8ea9b67..85c806fd 100644 --- a/ext/fg/float.html +++ b/ext/fg/float.html @@ -56,7 +56,8 @@ - + + -- cgit v1.2.3 From d106c638ed69b2c72895c1040b0e7bea2e31cdb7 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 21 Apr 2020 18:38:55 -0400 Subject: Move popup-nested content into float-main --- ext/fg/float.html | 1 - ext/fg/js/float-main.js | 48 +++++++++++++++++++++++++++++++++ ext/fg/js/popup-nested.js | 67 ----------------------------------------------- 3 files changed, 48 insertions(+), 68 deletions(-) delete mode 100644 ext/fg/js/popup-nested.js (limited to 'ext/fg/float.html') diff --git a/ext/fg/float.html b/ext/fg/float.html index 85c806fd..07c3c9e6 100644 --- a/ext/fg/float.html +++ b/ext/fg/float.html @@ -56,7 +56,6 @@ - diff --git a/ext/fg/js/float-main.js b/ext/fg/js/float-main.js index b752cdee..072c86e0 100644 --- a/ext/fg/js/float-main.js +++ b/ext/fg/js/float-main.js @@ -17,8 +17,56 @@ /* global * DisplayFloat + * apiOptionsGet */ +function injectPopupNested() { + const scriptSrcs = [ + '/mixed/js/text-scanner.js', + '/fg/js/frontend-api-sender.js', + '/fg/js/popup.js', + '/fg/js/popup-proxy.js', + '/fg/js/frontend.js', + '/fg/js/content-script-main.js' + ]; + for (const src of scriptSrcs) { + const script = document.createElement('script'); + script.async = false; + script.src = src; + document.body.appendChild(script); + } +} + +async function popupNestedInitialize(id, depth, parentFrameId, url) { + let optionsApplied = false; + + const applyOptions = async () => { + const optionsContext = {depth, url}; + const options = await apiOptionsGet(optionsContext); + const popupNestingMaxDepth = options.scanning.popupNestingMaxDepth; + + const maxPopupDepthExceeded = !( + typeof popupNestingMaxDepth === 'number' && + typeof depth === 'number' && + depth < popupNestingMaxDepth + ); + if (maxPopupDepthExceeded || optionsApplied) { + return; + } + + optionsApplied = true; + + window.frontendInitializationData = {id, depth, parentFrameId, url, proxy: true}; + injectPopupNested(); + + yomichan.off('optionsUpdated', applyOptions); + }; + + yomichan.on('optionsUpdated', applyOptions); + + await applyOptions(); +} + async function main() { new DisplayFloat(); } diff --git a/ext/fg/js/popup-nested.js b/ext/fg/js/popup-nested.js deleted file mode 100644 index 27482931..00000000 --- a/ext/fg/js/popup-nested.js +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2019-2020 Yomichan Authors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* global - * apiOptionsGet - */ - -function injectPopupNested() { - const scriptSrcs = [ - '/mixed/js/text-scanner.js', - '/fg/js/frontend-api-sender.js', - '/fg/js/popup.js', - '/fg/js/popup-proxy.js', - '/fg/js/frontend.js', - '/fg/js/content-script-main.js' - ]; - for (const src of scriptSrcs) { - const script = document.createElement('script'); - script.async = false; - script.src = src; - document.body.appendChild(script); - } -} - -async function popupNestedInitialize(id, depth, parentFrameId, url) { - let optionsApplied = false; - - const applyOptions = async () => { - const optionsContext = {depth, url}; - const options = await apiOptionsGet(optionsContext); - const popupNestingMaxDepth = options.scanning.popupNestingMaxDepth; - - const maxPopupDepthExceeded = !( - typeof popupNestingMaxDepth === 'number' && - typeof depth === 'number' && - depth < popupNestingMaxDepth - ); - if (maxPopupDepthExceeded || optionsApplied) { - return; - } - - optionsApplied = true; - - window.frontendInitializationData = {id, depth, parentFrameId, url, proxy: true}; - injectPopupNested(); - - yomichan.off('optionsUpdated', applyOptions); - }; - - yomichan.on('optionsUpdated', applyOptions); - - await applyOptions(); -} -- cgit v1.2.3