File tree Expand file tree Collapse file tree 1 file changed +20
-7
lines changed
Expand file tree Collapse file tree 1 file changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -54,13 +54,16 @@ function isStandalone() {
5454 return ! window . opener && window . parent === window ;
5555}
5656
57+ let interval ;
5758const createIframe = ( ) => {
5859 if ( ! isStandalone ( ) ) {
5960 return ;
6061 }
6162
6263 const iframe = document . createElement ( 'iframe' ) ;
63- iframe . setAttribute ( 'id' , 'open-sandbox' ) ;
64+
65+ const iframeId = `sb__open-sandbox${ Math . floor ( Math . random ( ) * 100 ) } ` ;
66+ iframe . setAttribute ( 'id' , iframeId ) ;
6467 const link = document . createElement ( 'a' ) ;
6568 setIframeStyle ( iframe ) ;
6669
@@ -89,14 +92,24 @@ const createIframe = () => {
8992 childList : true ,
9093 subtree : true ,
9194 } ) ;
95+
96+ clearInterval ( interval ) ;
97+ interval = setInterval ( ( ) => {
98+ // Check every second whether the button is still there
99+ if ( ! document . getElementById ( iframeId ) ) {
100+ createIframe ( ) ;
101+ }
102+ } , 1000 ) ;
92103 } ;
93104
94105 document . body . appendChild ( iframe ) ;
95106} ;
96- window . addEventListener ( 'load' , ( ) => {
97- try {
107+
108+ try {
109+ setTimeout ( ( ) => {
98110 createIframe ( ) ;
99- } catch ( e ) {
100- /* ignore */
101- }
102- } ) ;
111+ } , 250 ) ;
112+ } catch ( e ) {
113+ console . error ( e ) ;
114+ /* catch */
115+ }
You can’t perform that action at this time.
0 commit comments