Error while comunicating between CS and BGSW.

Hey all! I'm trying to build this extension that reads particular URLs in Discord (web) messages and replaces them with a custom UI that shows images, buttons, etc. This project is for an hackathon and we have a deadline by tomorrow morning, so I guess it's pretty urgent. The UI part works fine, the problem is that I cannot perform fetch calls from the content script since it gets blocked by Discord CSP. So I'm trying to send a message from the content script to the background service worker using @plasmohq/messaging, the problem is that I get a CSP error regarding the connection to ws://localhost:1815 and the messages stay hanging. Am I doing something wrong? The strange thing is that if I remove the world: "MAIN" it works fine, but I need the content script to be in the main world in order to access the window object because there's some data I need to fetch from other extensions that usually inject it there. The code is available at: https://github.com/builders-garden/shortcut-extension
GitHub
GitHub - builders-garden/shortcut-extension: Browser extension for ...
Browser extension for rendering and executing EVM Actions in the browser. - builders-garden/shortcut-extension
1 Reply
Avi
Avi•5mo ago
I have no idea about @plasmohq/messaging nor about world: "MAIN", but I do know that when you send a message from the content script to the background script, you can make an HTTP request to any URL that you want Though keep in mind that if you want to include fetch("", { credentials: "include" }) (i.e. include cookies with the HTTP request), you will need the domain listed in manifest.host_permissions
npm
@plasmohq/messaging
Type-safe, zero-config messaging library for modern browser extensions. Latest version: 0.6.2, last published: 6 months ago. Start using @plasmohq/messaging in your project by running npm i @plasmohq/messaging. There are 6 other projects in the npm registry using @plasmohq/messaging.
Want results from more Discord servers?
Add your server