let scriptInjection = new Set < string > ( ) ; const inject = ( fn ) => { const script = document . createElement ( 'script' ) ; fn ( script ) ; document . documentElement . appendChild ( script ) ; script . parentNode . removeChild ( script ) ; } ; const injectScript = ( path ) => { if ( scriptInjection . has ( path ) ) { return ; } inject ( script => { script . src = chrome . extension . getURL ( path ) ; } ) ; scriptInjection . add ( path ) ; } ; injectScript ( 'rx-devtools.bundle.js' ) ; window . addEventListener ( 'message' , function ( event ) { if ( event . source !== window ) { return ; } var message = event . data ; if ( typeof message !== 'object' || message === null || ! ( message . source === 'rx-devtools-plugin' ) ) { return ; } chrome . runtime . sendMessage ( message ) ; } ) ; chrome . runtime . onMessage . addListener ( function ( request , sender , sendResponse ) { console . log ( 'request' , request ) ; window . postMessage ( request , '*' ) ; } ) ;