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 23
23
"matches" : [" http://*/*" , " https://*/*" ],
24
24
"js" : [" contentScript.bundle.js" ],
25
25
"css" : [" contentScript.bundle.css" ],
26
- "run_at" : " document_end "
26
+ "run_at" : " document_start "
27
27
}
28
28
],
29
29
"web_accessible_resources" : [
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import { TranslateJobsProvider } from './providers/translate-jobs'
20
20
let isAppAttached = false
21
21
let lastSelection : TextSelection | undefined
22
22
let highlighter : any
23
+ let styleCache : ReturnType < typeof createCache >
23
24
24
25
const main = async ( ) => {
25
26
const container = document . createElement ( 'div' )
@@ -200,11 +201,19 @@ const getTextSelection = (selection: RangySelection): TextSelection => {
200
201
}
201
202
}
202
203
203
- const styleCache = createCache ( {
204
- key : 'ate' ,
205
- } )
206
-
207
204
const 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
+
208
217
if ( isAppAttached ) {
209
218
window . __ate_setClose && window . __ate_setClose ( false )
210
219
} else {
@@ -214,7 +223,7 @@ const initApp = (): void => {
214
223
< App />
215
224
</ TranslateJobsProvider >
216
225
</ CacheProvider > ,
217
- document . querySelector ( '#ate-container' ) ,
226
+ containerEl ,
218
227
)
219
228
isAppAttached = true
220
229
}
You can’t perform that action at this time.
0 commit comments