diff options
author | siikamiika <siikamiika@users.noreply.github.com> | 2020-03-19 00:00:42 +0200 |
---|---|---|
committer | siikamiika <siikamiika@users.noreply.github.com> | 2020-04-05 19:57:37 +0300 |
commit | 6806e7055f312ad1ff382118255ffe1004b7eace (patch) | |
tree | 018c02d893996f887d2b4a2fe71c6ded5610d18a /ext/fg/js/frontend-initialize.js | |
parent | 3684a479c5e12efe63c54e5532a264d157a6816d (diff) |
show iframe popups in root frame
Diffstat (limited to 'ext/fg/js/frontend-initialize.js')
-rw-r--r-- | ext/fg/js/frontend-initialize.js | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/ext/fg/js/frontend-initialize.js b/ext/fg/js/frontend-initialize.js index 3a191247..7f70d9c4 100644 --- a/ext/fg/js/frontend-initialize.js +++ b/ext/fg/js/frontend-initialize.js @@ -20,6 +20,7 @@ * Frontend * PopupProxy * PopupProxyHost + * apiForward */ async function main() { @@ -29,7 +30,25 @@ async function main() { const {id, depth=0, parentFrameId, url, proxy=false} = data; let popup; - if (proxy) { + if (!proxy && (window !== window.parent)) { + let rootPopupInformationResolve; + const rootPopupInformationPromise = new Promise((resolve) => (rootPopupInformationResolve = resolve)); + + const runtimeMessageCallback = ({action, params}, sender, callback) => { + if (action === 'rootPopupInformation') { + chrome.runtime.onMessage.removeListener(runtimeMessageCallback); + callback(); + rootPopupInformationResolve(params); + return false; + } + }; + chrome.runtime.onMessage.addListener(runtimeMessageCallback); + apiForward('rootPopupInformationGet'); + + const {popupId, frameId} = await rootPopupInformationPromise; + + popup = new PopupProxy(popupId, 0, null, frameId, url); + } else if (proxy) { popup = new PopupProxy(null, depth + 1, id, parentFrameId, url); } else { const popupHost = new PopupProxyHost(); |