hrtools/content/inject.js

33 lines
606 B
JavaScript
Raw Permalink Normal View History

2021-04-26 10:42:12 +00:00
2021-04-27 10:36:08 +00:00
if( window.location.href === "http://localhost:12203/start") {
2021-04-26 10:42:12 +00:00
2021-04-27 10:36:08 +00:00
var ws = new WebSocket("ws://localhost:12203/task");
ws.onopen = function(evt) {
console.log("Connection open ...", evt);
ws.send("Hello WebSockets!");
};
ws.onmessage = function(evt) {
console.log("Received Message: ", JSON.parse(evt.data));
chrome.runtime.sendMessage(JSON.parse(evt.data))
};
ws.onclose = function(evt) {
console.log("Connection closed.");
};
ws.onerror = function(evt) {
console.log(evt);
}
}
2021-04-26 10:42:12 +00:00