-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
36 lines (32 loc) · 997 Bytes
/
content.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
const pushButton = (direction) => {
const buttons = document.getElementsByTagName("button");
console.log(direction);
console.log("Number of buttons =", buttons.length);
for (let i = 0; i < buttons.length; i++) {
if (buttons[i].getAttribute("aria-label") === direction) {
buttons[i].click();
break;
}
if (buttons[i].textContent.includes(direction)) {
buttons[i].click();
break;
}
}
};
document.addEventListener("keydown", function (event) {
const isPreviousDay = event.code === "BracketLeft";
const isNextDay = event.code === "BracketRight";
const isToday = event.code === "Backslash";
const isInbox = event.code === "KeyI";
if (event.altKey && event.metaKey && event.shiftKey && event.ctrlKey) {
if (isPreviousDay) {
pushButton("Previous day");
} else if (isNextDay) {
pushButton("Next day");
} else if (isToday) {
pushButton("Today");
} else if (isInbox) {
pushButton("Inbox");
}
}
});