import { withErrorLog } from 'analytics' ; import { Gitako } from 'components/Gitako' ; import { addMiddleware } from 'driver/connect' ; import { platform } from 'platforms' ; import * as React from 'react' ; import * as ReactDOM from 'react-dom' ; import './content.scss' ; if ( platform . resolvePartialMetaData ( ) ) { addMiddleware ( withErrorLog ) ; if ( document . readyState === 'loading' ) { document . addEventListener ( 'DOMContentLoaded' , init ) ; } else { init ( ) ; } } async function init ( ) { await injectStyles ( browser . extension . getURL ( 'content.css' ) ) ; const SideBarElement = document . createElement ( 'div' ) ; document . body . appendChild ( SideBarElement ) ; ReactDOM . render ( < Gitako />, SideBarElement); } async function injectStyles ( url ) { return new Promise < void > ( resolve => { const linkElement = document . createElement ( 'link' ) ; linkElement . setAttribute ( 'rel' , 'stylesheet' ) ; linkElement . setAttribute ( 'href' , url ) ; linkElement . onload = ( ) => resolve ( ) ; document . head . appendChild ( linkElement ) ; } ) ; }