[Q/A] How to append_child using contents_script Custom Root Container #578
Replies: 2 comments
-
This is the case because you're watching over the entire nav with You can tweak that query to watch for a sub element |
Beta Was this translation helpful? Give feedback.
-
You can also create a new element inside your selector like so:
|
Beta Was this translation helpful? Give feedback.
-
What happened?
I want to add a child element under the ”nav“ element once the nav sub elements have fully loaded. However, my current code is replacing all the existing children under the "nav".
the html:
"
_
script:
**export const getRootContainer = () =>
new Promise((resolve) => {
const checkInterval = setInterval(() => {
const rootContainer = document.querySelector("nav")
if (rootContainer) {
clearInterval(checkInterval)
resolve(rootContainer)
}
}, 137)
})
const PlasmoOverlay = () => {
return (
style={{
background: "yellow",
padding: 12
}}>
HELLO WORLD ROOT CONTAINER
export const render = async ({ createRootContainer }) => {
const rootContainer = await createRootContainer()
const root = createRoot(rootContainer)
root.render()
}
export default PlasmoOverlay**
Version
Latest
What OS are you seeing the problem on?
Windows
What browsers are you seeing the problem on?
Chrome
Relevant log output
No response
(OPTIONAL) Contact Details
No response
Code of Conduct
Beta Was this translation helpful? Give feedback.
All reactions