@@ -66,6 +66,35 @@ const initTranslationStr = () => {
6666 document . documentElement . getAttribute ( 'lang' ) || String . defaultLocale ;
6767} ;
6868
69+ const onLoaded = ( ) => {
70+ window . addEventListener ( 'message' , onMessage , false ) ;
71+ window . parent . postMessage ( '{"MessageId":"settings-ready"}' , '*' ) ;
72+ } ;
73+
74+ const onMessage = ( e ) => {
75+ try {
76+ const data = JSON . parse ( e . data ) ;
77+ if ( e . origin === window . origin && window . parent !== window . self ) {
78+ if ( data . MessageId === 'settings-ready' )
79+ window . parent . postMessage ( '{"MessageId":"settings-show"}' , '*' ) ;
80+ else if ( data . MessageId === 'settings-save-all' ) {
81+ const saveButtons = [
82+ 'xcu-save-button' ,
83+ 'browser-settings-save-button' ,
84+ 'document-settings-save-button' ,
85+ ] ;
86+ for ( const i in saveButtons ) {
87+ const button = document . getElementById ( saveButtons [ i ] ) ;
88+ button ?. click ( ) ;
89+ }
90+ }
91+ }
92+ } catch ( err ) {
93+ console . error ( 'Could not process postmessage:' , err ) ;
94+ return ;
95+ }
96+ } ;
97+
6998const defaultBrowserSetting : Record < string , any > = {
7099 compactMode : {
71100 value : false ,
@@ -347,7 +376,7 @@ class SettingIframe {
347376
348377 if ( ! response . ok ) {
349378 console . error (
350- 'something wend wrong shared config response' ,
379+ 'something went wrong shared config response' ,
351380 response . text ( ) ,
352381 ) ;
353382 throw new Error (
@@ -1609,3 +1638,4 @@ document.addEventListener('DOMContentLoaded', () => {
16091638} ) ;
16101639
16111640( window as any ) . _ = _ ;
1641+ ( window as any ) . onload = onLoaded ;
0 commit comments