Skip to content
This repository was archived by the owner on Aug 16, 2024. It is now read-only.

Commit 699948e

Browse files
committed
fix: conflict with emotion 10 application
1 parent 4e46590 commit 699948e

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
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": [

src/pages/Content/index.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { TranslateJobsProvider } from './providers/translate-jobs'
2020
let isAppAttached = false
2121
let lastSelection: TextSelection | undefined
2222
let highlighter: any
23+
let styleCache: ReturnType<typeof createCache>
2324

2425
const 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-
207204
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+
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
}

0 commit comments

Comments
 (0)