diff --git a/chrome/content.js b/chrome/content.js index 4bec7cd9..5557e169 100644 --- a/chrome/content.js +++ b/chrome/content.js @@ -131,6 +131,12 @@ if (oldFrameObj.windowedFullscreenState.active) { windowedFullscreenToggle(oldFrameObj); } + + if (oldFrameObj.iframe !== iframeElement) { + iframeElement.addEventListener('load', frameLoadListener); + } + } else { + iframeElement.addEventListener('load', frameLoadListener); } iframeMap.set(request.frameId, newFrameObj); @@ -139,6 +145,29 @@ } }); + function frameLoadListener(e) { + // Find match in iframeMap + const iframeElement = e.target; + let frameObj = null; + iframeMap.forEach((value) => { + if (value.iframe === iframeElement) { + frameObj = value; + } + }); + + if (!frameObj) { + return; + } + + if (frameObj.miniplayerState.active) { + unmakeMiniPlayer(frameObj); + } + + if (frameObj.windowedFullscreenState.active) { + windowedFullscreenToggle(frameObj); + } + } + async function sendToOtherContents(message) { chrome.runtime.sendMessage({ type: 'SEND_TO_CONTENT',