Yes, there is a similar question to this already has already been answered (Chrome Extension Socket io node js); however, it only works for background scripts (from what I've seen). So, how would I do this in the content script?
Here is what I have so far:
// manifest.json
// And yes, I've also tried to import "socket.io.js" as a background script
"content_scripts":
[
{
"matches": ["<all_urls>"],
"js": ["socket.io.js", "index.js"]
}
]
// index.js
const socket = io('http://localhost:8080');
socket.on('some-event', (data) => {
...
};
// index.js:1 Uncaught ReferenceError: io is not defined
// at index.js:1
What am I doing wrong?
Thanks.