mirror of
https://github.com/yaklang/yaklang-chrome-extension.git
synced 2026-09-26 21:21:53 +08:00
add basic dev boostrap
This commit is contained in:
+10
-5
@@ -40,15 +40,20 @@ heartbeat()
|
||||
setInterval(heartbeat, 3000)
|
||||
|
||||
console.info("Chrome Extenstion Background is loaded")
|
||||
|
||||
chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
|
||||
if (msg.action === "connectWebsocket") {
|
||||
if (msg.action === "connect") {
|
||||
console.info("Start to connect websocket")
|
||||
connectWebsocket(msg.url)
|
||||
} else if (msg.action === "init") {
|
||||
const host = msg['host'] || "127.0.0.1"
|
||||
const port = msg['port'] || 11212
|
||||
connectWebsocket(`ws://${host}:${port}/?token=${"a"}`)
|
||||
} else if (msg.action === 'disconnect') {
|
||||
disconnectWebsocket()
|
||||
} else if (msg.action === "status") {
|
||||
if (socket) {
|
||||
chrome.runtime.sendMessage({status: "connected"})
|
||||
chrome.runtime.sendMessage({connected: true})
|
||||
} else {
|
||||
chrome.runtime.sendMessage({status: "initialized"})
|
||||
chrome.runtime.sendMessage({connected: false})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user