-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
41 lines (36 loc) · 1.43 KB
/
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var port = chrome.runtime.connectNative(hostName);
port.onMessage.addListener((message) => {
console.log(message);
});
chrome.storage.sync.get(["key"]).then((result) => {
document.getElementById('keyCTRL').checked = result.key.kctrl;
document.getElementById('keySHIFT').checked = result.key.kshift;
document.getElementById('keyALT').checked = result.key.kalt;
document.getElementById('keyText').value = result.key.ktext;
});
document.addEventListener("keydown", async (event) => {
document.getElementById('keyText').value = event.key.toUpperCase();
});
document.getElementById("btnSave").addEventListener("click", () => {
var hotkey = {
kctrl: document.getElementById('keyCTRL').checked,
kshift: document.getElementById('keySHIFT').checked,
kalt: document.getElementById('keyALT').checked,
ktext: document.getElementById('keyText').value.toUpperCase()
}
// chrome.storage.sync.set({ 'key': hotkey }, function() {
// });
var hostName = "com.blue.chrome.load.host";
port.postMessage('werwer');
console.log("sdfsdf")
// chrome.storage.sync.get(["key"]).then((result) => {
// var msg = {
// 'SCTRL': result.key.kctrl,
// 'SSHIFT': result.key.kshift,
// 'SALT': result.key.kalt,
// 'SCODE': result.key.ktext.charCodeAt(0)
// }
// console.log(msg);
// console.log(JSON.stringify(msg));
// });
});