added hotkeys
This commit is contained in:
parent
9863115881
commit
1af6a21beb
@ -4,8 +4,8 @@
|
|||||||
<link rel="stylesheet" href="popup.css" />
|
<link rel="stylesheet" href="popup.css" />
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="link save">Save tabs to file</div>
|
<div class="link save"><u>S</u>ave tabs to file</div>
|
||||||
<div class="link restore">Restore tabs from file</div>
|
<div class="link restore"><u>R</u>estore tabs from file</div>
|
||||||
<script src="popup.js"></script>
|
<script src="popup.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
21
popup.js
21
popup.js
@ -3,9 +3,22 @@ chrome.windows.getCurrent((_window) => {
|
|||||||
currentWindow = _window;
|
currentWindow = _window;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let saveButton = document.querySelector("div.link.save");
|
||||||
|
let restoreButton = document.querySelector("div.link.restore");
|
||||||
|
|
||||||
window.addEventListener("keydown", (event) => {
|
window.addEventListener("keydown", (event) => {
|
||||||
if (event.keyCode == 27) {
|
switch (event.key) {
|
||||||
window.close();
|
case "s":
|
||||||
|
case "S":
|
||||||
|
saveButton.click();
|
||||||
|
break;
|
||||||
|
case "r":
|
||||||
|
case "R":
|
||||||
|
restoreButton.click();
|
||||||
|
break;
|
||||||
|
case "Escape":
|
||||||
|
window.close();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -59,5 +72,5 @@ async function restore(event) {
|
|||||||
window.close();
|
window.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
document.querySelector("div.link.save").addEventListener("click", save);
|
saveButton.addEventListener("click", save);
|
||||||
document.querySelector("div.link.restore").addEventListener("click", restore);
|
restoreButton.addEventListener("click", restore);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user