aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/frontend-initialize.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2020-04-10 09:38:07 -0700
committerAlex Yatskov <alex@foosoft.net>2020-04-10 09:38:07 -0700
commit3ed49205f2af076e3c5b4fe371d8a0a420845581 (patch)
treeab0c0fd9638aaa6a842bc4f17e73754ca7d26bd9 /ext/fg/js/frontend-initialize.js
parentb77e2afe3a8ef9e96a53dd8ca97d8b913941244b (diff)
parent281023095a9fb7f7aca1df8dc0e3f902e78dc16b (diff)
Merge branch 'master' into testing
Diffstat (limited to 'ext/fg/js/frontend-initialize.js')
-rw-r--r--ext/fg/js/frontend-initialize.js34
1 files changed, 31 insertions, 3 deletions
diff --git a/ext/fg/js/frontend-initialize.js b/ext/fg/js/frontend-initialize.js
index 8424b21d..4a1409db 100644
--- a/ext/fg/js/frontend-initialize.js
+++ b/ext/fg/js/frontend-initialize.js
@@ -17,28 +17,56 @@
*/
/* global
+ * FrameOffsetForwarder
* Frontend
* PopupProxy
* PopupProxyHost
+ * apiForward
+ * apiOptionsGet
*/
async function main() {
await yomichan.prepare();
const data = window.frontendInitializationData || {};
- const {id, depth=0, parentFrameId, ignoreNodes, url, proxy=false} = data;
+ const {id, depth=0, parentFrameId, url, proxy=false} = data;
+
+ const optionsContext = {depth, url};
+ const options = await apiOptionsGet(optionsContext);
let popup;
- if (proxy) {
+ if (!proxy && (window !== window.parent) && options.general.showIframePopupsInRootFrame) {
+ const rootPopupInformationPromise = yomichan.getTemporaryListenerResult(
+ chrome.runtime.onMessage,
+ ({action, params}, {resolve}) => {
+ if (action === 'rootPopupInformation') {
+ resolve(params);
+ }
+ }
+ );
+ apiForward('rootPopupRequestInformationBroadcast');
+ const {popupId, frameId} = await rootPopupInformationPromise;
+
+ const frameOffsetForwarder = new FrameOffsetForwarder();
+ frameOffsetForwarder.start();
+ const getFrameOffset = frameOffsetForwarder.getOffset.bind(frameOffsetForwarder);
+
+ popup = new PopupProxy(popupId, 0, null, frameId, url, getFrameOffset);
+ await popup.prepare();
+ } else if (proxy) {
popup = new PopupProxy(null, depth + 1, id, parentFrameId, url);
+ await popup.prepare();
} else {
+ const frameOffsetForwarder = new FrameOffsetForwarder();
+ frameOffsetForwarder.start();
+
const popupHost = new PopupProxyHost();
await popupHost.prepare();
popup = popupHost.getOrCreatePopup(null, null, depth);
}
- const frontend = new Frontend(popup, ignoreNodes);
+ const frontend = new Frontend(popup);
await frontend.prepare();
}