add popup.js and background

This commit is contained in:
VillanCh
2024-03-20 09:35:46 +08:00
parent 76972971a4
commit ac483f9eb7
3 changed files with 74 additions and 4 deletions
+14
View File
@@ -0,0 +1,14 @@
document.getElementById('connectBtn').addEventListener('click', () => {
let wsUrl = document.getElementById('wsUrl').value;
if (!wsUrl) {
wsUrl = 'ws://127.0.0.1:8881/?token=a'
}
const msg = {
action: "connectWebsocket", url: wsUrl,
};
chrome.runtime.sendMessage(msg)
})
chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => {
document.getElementById("wsStatus").innerText = msg.status;
});