declare var browser ; window . browser = ( function ( ) { return ( window . msBrowser || window . browser || window . chrome ) ; } ) ( ) ; const state = { injected : false , } ; browser . runtime . onMessage . addListener ( ( message ) => { if ( message . action === "inject-editor" && state . injected === false ) { state . injected = true ; const localUrl = browser . runtime . getURL ( "dist/editor.js" ) ; fetch ( localUrl ) . then ( async ( response ) => { const code = await response . text ( ) ; const script = document . createElement ( "script" ) ; script . innerHTML = code ; document . head . appendChild ( script ) ; } ) ; } } ) ;