File tree Expand file tree Collapse file tree
companion/extension/entrypoints Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ export default defineContentScript({
3838
3939 let isVisible = false ;
4040 let isClosed = true ;
41+ let iframeLoaded = false ;
4142
4243 // Create sidebar container
4344 const sidebarContainer = document . createElement ( "div" ) ;
@@ -69,7 +70,6 @@ export default defineContentScript({
6970 // - ext:build-prod → uses https://companion.cal.com
7071 const COMPANION_URL =
7172 ( import . meta. env . EXPO_PUBLIC_COMPANION_DEV_URL as string ) || "https://companion.cal.com" ;
72- iframe . src = COMPANION_URL ;
7373 // Enable clipboard access for the cross-origin iframe
7474 // This allows the companion app to use navigator.clipboard.writeText()
7575 iframe . allow = "clipboard-write; clipboard-read" ;
@@ -90,6 +90,8 @@ export default defineContentScript({
9090
9191 // Listen for messages from iframe to control width and handle OAuth
9292 window . addEventListener ( "message" , ( event ) => {
93+ if ( ! iframeLoaded ) return ;
94+
9395 // Security: Only accept messages from our iframe's origin
9496 // This prevents malicious scripts on the host page from manipulating the companion
9597 const iframeOrigin = new URL ( iframe . src ) . origin ;
@@ -505,6 +507,10 @@ export default defineContentScript({
505507
506508 // Function to open the sidebar
507509 function openSidebar ( ) {
510+ if ( ! iframeLoaded ) {
511+ iframe . src = COMPANION_URL ;
512+ iframeLoaded = true ;
513+ }
508514 if ( isClosed ) {
509515 isClosed = false ;
510516 isVisible = true ;
You can’t perform that action at this time.
0 commit comments