aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/frontend-initialize.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fg/js/frontend-initialize.js')
-rw-r--r--ext/fg/js/frontend-initialize.js18
1 files changed, 7 insertions, 11 deletions
diff --git a/ext/fg/js/frontend-initialize.js b/ext/fg/js/frontend-initialize.js
index 51fa8d7a..97e315b5 100644
--- a/ext/fg/js/frontend-initialize.js
+++ b/ext/fg/js/frontend-initialize.js
@@ -32,19 +32,15 @@ async function main() {
let popup;
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);
+ const rootPopupInformationPromise = yomichan.getTemporaryListenerResult(
+ chrome.runtime.onMessage,
+ ({action, params}, {resolve}) => {
+ if (action === 'rootPopupInformation') {
+ resolve(params);
+ }
}
- };
- chrome.runtime.onMessage.addListener(runtimeMessageCallback);
+ );
apiForward('rootPopupRequestInformationBroadcast');
-
const {popupId, frameId} = await rootPopupInformationPromise;
const frameOffsetForwarder = new FrameOffsetForwarder();