bwbama85
bwbama85
PD🧩 Plasmo Developers
Created by bwbama85 on 6/14/2023 in #🔰newbie
Multiple root containers question
I have a content script inserts a new root container in a website.:
export const getRootContainer = () =>
new Promise((resolve) => {
const checkInterval = setInterval(() => {
const desktopContainerParent = document.querySelector(
"div.desktopOnly span.topBarDetails span.delegatesShortcut.clickable"
)
if (desktopContainerParent) {
clearInterval(checkInterval)
const desktopRootContainer = document.createElement("span")
desktopContainerParent.after(desktopRootContainer)
resolve(desktopRootContainer)
}
}, 137)
})

export const render: PlasmoRender<PlasmoCSUIJSXContainer> = async ({ createRootContainer }) => {
const rootContainer = await createRootContainer()
const root = createRoot(rootContainer)
root.render(<OilOverlay />)
}
export const getRootContainer = () =>
new Promise((resolve) => {
const checkInterval = setInterval(() => {
const desktopContainerParent = document.querySelector(
"div.desktopOnly span.topBarDetails span.delegatesShortcut.clickable"
)
if (desktopContainerParent) {
clearInterval(checkInterval)
const desktopRootContainer = document.createElement("span")
desktopContainerParent.after(desktopRootContainer)
resolve(desktopRootContainer)
}
}, 137)
})

export const render: PlasmoRender<PlasmoCSUIJSXContainer> = async ({ createRootContainer }) => {
const rootContainer = await createRootContainer()
const root = createRoot(rootContainer)
root.render(<OilOverlay />)
}
I would like to add a new root container so that I can attach OilOverlay to it as well.
div.mobileOnly span.topBarDetails span.delegatesShortcut.clickable
div.mobileOnly span.topBarDetails span.delegatesShortcut.clickable
Right now the only one that works is the Desktop one. Replicating the code in a new content script and searching for the mobile class instead of desktop does not work. What am I missing here?
11 replies
PD🧩 Plasmo Developers
Created by bwbama85 on 6/6/2023 in #👟framework
Importing NPM Module JavaScript into web page issue
2 replies