Closed the-wc closed 9 months ago
This is a rookie mistake. You cannot access the chrome.runtime
in main
world.
However main
world scripts are injected prevents you from accessing the chrome.runtime
properties like onMessage
or addListener
. So, you will not be able to access useMessage
or have a receipient for sendToContentScript
, which rely on the runtime
.
Simple example:
export const config: PlasmoCSConfig = {
// Do not include the below in your content script, if you need to access the `chrome.runtime` properties
// world: "MAIN"
}
What happened?
useMessage
ORchrome.runtime.onMessage.addListener
results in:onMessage.addListener
is undefined. Hoping that I'm just misconfigured, but here's the code:Manifest Configuration:
Version
Latest
What OS are you seeing the problem on?
Linux
What browsers are you seeing the problem on?
Chrome
Relevant log output
(OPTIONAL) Contribution
Code of Conduct