Commit 3698084 1 parent d89340f commit 3698084 Copy full SHA for 3698084
File tree 1 file changed +2
-20
lines changed
1 file changed +2
-20
lines changed Original file line number Diff line number Diff line change 1
1
export const isInIframe = ( ( ) => {
2
2
try {
3
- // Check if in iframe
4
- const isInIframe = window . self !== window . top ;
5
-
6
- if ( ! isInIframe ) return true ;
7
-
8
- // Check for Home Assistant specific objects or elements
9
- const hasHAElements =
10
- // Check if Home Assistant custom elements exist in parent document
11
- window . parent ?. customElements ?. get ( "home-assistant" ) !== undefined ||
12
- // Check URL for typical Home Assistant paths
13
- window . location . href . includes ( "/api/hassio" ) ||
14
- // Check for typical Home Assistant URL patterns in referrer
15
- document . referrer . includes ( "homeassistant" ) ||
16
- document . referrer . includes ( "/api/hassio_ingress/" ) ||
17
- // Check parent URL if accessible
18
- window . parent ?. location ?. href ?. includes ( "homeassistant" ) ||
19
- false ;
20
-
21
- return hasHAElements ;
3
+ return window . self !== window . top ;
22
4
} catch ( e ) {
23
- // If security error occurs when checking iframe , we're definitely in a cross-origin iframe
5
+ // If we get a security error , we're definitely in an iframe
24
6
return true ;
25
7
}
26
8
} ) ( ) ;
You can’t perform that action at this time.
0 commit comments