I’m currently trying to make a chrome extension with socket io client running in the background but it doesn’t seem to work.
I read that you need to reference the socket io dist but that doesnt seem to work either.
Html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<script src="node_modules/socket.io-client/dist/socket.io.js"></script>
</head>
<body>
<nav class="container">
<nav class="roomChoice" id="roomChoice">
<p id="directionLabel">Create or join a link to view Crunchyroll together</p>
<button id="create">Create</button>
<button id="join">Join</button>
</nav>
<nav class="joinRoom" id="joinRoom">
<p>Enter room code below</p>
<input type="text" id="roomInput" placeholder="CODE">
<button id="joinBtn">Join</button>
</nav>
<nav class="createRoom" id="createRoom">
<p>Below is your room code</p>
<input type="text" id="codeDisplay" readonly>
</nav>
</nav>
<script src="src/scripts/popup.js"></script>
<script src="background.js"></script>
</body>
</html>
manifest.json:
{
"manifest_version": 3,
"name": "Minimal Manifest",
"version": "1.0.0",
"description": "A basic example extension with only required keys",
"icons": {
"68" : "src/images/Site_Icon.png"
},
"action": {
"default_popup": "popup.html"
},
"background": {
"service_worker": "background.js"
},
"content_scripts": [
{
"matches": ["https://*.basicdomain.com/*"],
"js": ["content.js"]
}
]
}
background.js:
console.log("Background script loaded");
const socket = io('basicdomain.com');
I’ve also attached a screenshot of the dist locationsocketio dist
New contributor
Jacob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.