-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
43 lines (36 loc) · 1.16 KB
/
script.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
const onMessage = () => {
// Are we in a call?
if (document.querySelector('button[aria-label*="Raise hand"]')) {
fixButton();
removeEventListener("message", onMessage);
}
};
// Listen for changes to the page
addEventListener("message", onMessage);
const fixButton = () => {
// Keep track of whether the hand is currently raised
let handRaised = false;
// Clone the 'Raise hand' button
const originalButton = document.querySelector(
'button[aria-label*="Raise hand"]'
);
const original = originalButton.parentElement.parentElement.parentElement;
const clone = original.cloneNode(true);
const cloneButton = clone.querySelector("button");
original.after(clone);
// Hide the original button
original.style.display = "none";
// Tweak the action to include a confirmation dialog
cloneButton.removeAttribute("jsaction");
cloneButton.addEventListener("click", () => {
if (
handRaised ||
window.confirm("Do you actually want to raise your hand?")
) {
// Click the original button
originalButton.click();
cloneButton.className = originalButton.className;
handRaised = !handRaised;
}
});
};