-
Notifications
You must be signed in to change notification settings - Fork 4
/
popup.js
28 lines (25 loc) · 876 Bytes
/
popup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const tabs =await chrome.tabs.query({});
const tabsSelectDom = document.getElementById("tabs");
const serverDom = document.getElementById("server")
for (const tab of tabs) {
let option = document.createElement("option");
option.text = tab.title;
option.value = tab.id;
tabsSelectDom.add(option);
}
const localServer = localStorage.getItem("server");
if(localServer){
serverDom.value = localServer;
}
serverDom.addEventListener('change', (e)=> {
const serverDom = document.getElementById("server")
const server = serverDom.value;
localStorage.setItem("server",server);
});
tabsSelectDom.addEventListener('change', (e)=> {
const serverDom = document.getElementById("server")
const server = serverDom.value;
(async ()=>{
const response = await chrome.runtime.sendMessage({id:e.target.value,server:server});
})();
});