-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwelcome.js
49 lines (41 loc) · 1.12 KB
/
welcome.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
42
43
44
45
46
47
48
49
class WelcomePage {
constructor() {
this.init();
}
init() {
// Add smooth scroll behavior
document.querySelectorAll('a[href^="#"]').forEach((anchor) => {
anchor.addEventListener("click", (e) => {
e.preventDefault();
const target = document.querySelector(anchor.getAttribute("href"));
target.scrollIntoView({ behavior: "smooth" });
});
});
// Register keyboard shortcuts
this.registerKeyboardShortcuts();
}
registerKeyboardShortcuts() {
const shortcuts = {
"Alt+S": this.openExtension,
"Alt+C": this.copySelectedSVG,
"Alt+A": this.selectAllSVGs,
};
document.addEventListener("keydown", (e) => {
const key = `${e.altKey ? "Alt+" : ""}${e.key.toUpperCase()}`;
if (shortcuts[key]) {
e.preventDefault();
shortcuts[key]();
}
});
}
openExtension() {
chrome.runtime.sendMessage({ action: "openPopup" });
}
copySelectedSVG() {
chrome.runtime.sendMessage({ action: "copySelected" });
}
selectAllSVGs() {
chrome.runtime.sendMessage({ action: "selectAll" });
}
}
new WelcomePage();