This repository was archived by the owner on Aug 16, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change 2323 "matches" : [" http://*/*" , " https://*/*" ],
2424 "js" : [" contentScript.bundle.js" ],
2525 "css" : [" contentScript.bundle.css" ],
26- "run_at" : " document_end "
26+ "run_at" : " document_start "
2727 }
2828 ],
2929 "web_accessible_resources" : [
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import { TranslateJobsProvider } from './providers/translate-jobs'
2020let isAppAttached = false
2121let lastSelection : TextSelection | undefined
2222let highlighter : any
23+ let styleCache : ReturnType < typeof createCache >
2324
2425const main = async ( ) => {
2526 const container = document . createElement ( 'div' )
@@ -200,11 +201,19 @@ const getTextSelection = (selection: RangySelection): TextSelection => {
200201 }
201202}
202203
203- const styleCache = createCache ( {
204- key : 'ate' ,
205- } )
206-
207204const initApp = ( ) : void => {
205+ const containerEl = document . querySelector ( '#ate-container' )
206+
207+ if ( ! containerEl ) {
208+ return
209+ }
210+
211+ if ( ! styleCache ) {
212+ styleCache = createCache ( {
213+ key : 'ate' ,
214+ } )
215+ }
216+
208217 if ( isAppAttached ) {
209218 window . __ate_setClose && window . __ate_setClose ( false )
210219 } else {
@@ -214,7 +223,7 @@ const initApp = (): void => {
214223 < App />
215224 </ TranslateJobsProvider >
216225 </ CacheProvider > ,
217- document . querySelector ( '#ate-container' ) ,
226+ containerEl ,
218227 )
219228 isAppAttached = true
220229 }
You can’t perform that action at this time.
0 commit comments