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() {
54
54
return ! window . opener && window . parent === window ;
55
55
}
56
56
57
+ let interval ;
57
58
const createIframe = ( ) => {
58
59
if ( ! isStandalone ( ) ) {
59
60
return ;
60
61
}
61
62
62
63
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 ) ;
64
67
const link = document . createElement ( 'a' ) ;
65
68
setIframeStyle ( iframe ) ;
66
69
@@ -89,14 +92,24 @@ const createIframe = () => {
89
92
childList : true ,
90
93
subtree : true ,
91
94
} ) ;
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 ) ;
92
103
} ;
93
104
94
105
document . body . appendChild ( iframe ) ;
95
106
} ;
96
- window . addEventListener ( 'load' , ( ) => {
97
- try {
107
+
108
+ try {
109
+ setTimeout ( ( ) => {
98
110
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