fancy-intern-4869
07/23/2022, 4:27 PMtypescript
// Handle action click in content-script (using webext-bridge)
onMessage("showModal", async ({ data }) => {
// early return
if (!data.message) return { success: false }
const plasmoShadowHost = document.getElementById("plasmo-shadow-host")
if (!plasmoShadowHost) {
alert(`shadow root not found!`) // NOTE: I'm unable to find this element easily right now.
return { success:false }
}
// toggle visibility of my extension
plasmoShadowHost.style.display = plasmoShadowHost.style.display === "none" ? "flex" : "none"; // NOTE: Using flex here but can also be whatever, really
return { success: true }
})