tbrockman
tbrockman
PD🧩 Plasmo Developers
Created by tbrockman on 1/14/2024 in #👾extension
How can I listen for messages from the extension popup in ALL (there could be many) active contents?
I have the following configuration for a UI content-script (although I don't actually need the UI -- the content script is only used to add listeners for UI interactions and instrument HTTP requests from the injected page automatically, it just seemed like the messaging hooks might be more ergonomic):
export const config: PlasmoCSConfig = {
matches: ["<all_urls>"],
world: "MAIN",
run_at: "document_start"
}
export const config: PlasmoCSConfig = {
matches: ["<all_urls>"],
world: "MAIN",
run_at: "document_start"
}
I'd like to be able to receive updates in the content script when the popup makes changes to a configuration variable, so I added in test code to the content-script to listen to a port:
const content = () => {
const mailPort = usePort("mail")

return <>
{mailPort.data?.message}
</>
}

export default content
const content = () => {
const mailPort = usePort("mail")

return <>
{mailPort.data?.message}
</>
}

export default content
But this results in the following error:
content.0c6b4643.js:1 Uncaught Error: Extension runtime is not available
4 replies
PD🧩 Plasmo Developers
Created by tbrockman on 5/13/2023 in #👟framework
Is it possible to specify per browser permissions?
So, the context around this question is that my extension leverages the tabGroups API, which isn't available in Firefox, and doesn't seem likely to be implemented for a very long time, but I would still like to be able to release something for Firefox. I know that I can add logic that only executes code on certain browsers, which is checked at compile-time, but is there anything I can do to have the tabGroups permission (for example) only be requested in compiled manifests targeting a specific browser?
7 replies
PD🧩 Plasmo Developers
Created by tbrockman on 4/23/2023 in #👟framework
MUI Select component attachment point in CSUI?
Just wondering if anyone else has ran into this and what the correct fix should be. Seems like for <Select> components in CSUI when you open the dropdown the corresponding <Popover> doesn't attach to the correct element, and is appended to the document body instead, leading to the dropdown being rendered at the bottom of the page rather than directly underneath the <Select> input. The following queries also return null/empty. What am I missing here?
console.log(document.getElementById('plasmo-shadow-container')) # null
console.log(document.getElementsByClassName('plasmo-csui-container')) # []
console.log(document.getElementById('plasmo-shadow-container')) # null
console.log(document.getElementsByClassName('plasmo-csui-container')) # []
7 replies