-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwave.js
95 lines (91 loc) · 3.23 KB
/
wave.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
function sendEmoji(emoji) {
if (((document.querySelector("[aria-label='Send a message to everyone']")) == null)) { //Check if the sidebar is closed
document.querySelector("[aria-label='Chat with everyone']").click(); //Open chat sidebar
document.querySelector("[aria-label='Send a message to everyone']").value = emoji;
document.querySelector(".VfPpkd-Bz112c-LgbsSe.yHy1rc.eT1oJ.tWDL4c.Cs0vCd").removeAttribute("disabled");
document.querySelector(".VfPpkd-Bz112c-LgbsSe.yHy1rc.eT1oJ.tWDL4c.Cs0vCd").click();
// document.querySelector("[aria-label='Close']").click(); //Close chat sidebar
}
else {
document.querySelector("[aria-label='Send a message to everyone']").value = emoji;
document.querySelector(".VfPpkd-Bz112c-LgbsSe.yHy1rc.eT1oJ.tWDL4c.Cs0vCd").removeAttribute("disabled");
document.querySelector(".VfPpkd-Bz112c-LgbsSe.yHy1rc.eT1oJ.tWDL4c.Cs0vCd").click();
}
}
(async () => {
// Wait until in call
while (document.querySelector(".d7iDfe") !== null) {
await new Promise((r) => setTimeout(r, 500));
}
var username;
if (localStorage.getItem('username')) {
username = localStorage.getItem('username');
} else {
username = prompt("What is your name?");
localStorage.setItem('username', username);
}
document.querySelector("[aria-label='Chat with everyone']").click();
var waveApp = document.createElement("div");
waveApp.innerHTML = `
<style>#waveAppContainer {
position: fixed;
top: 0;
left: 0;
background-color: #fff !important;
border-bottom-right-radius: 8px;
z-index: 1;
text-align: center;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
.waveButton{
background-color: #fff;
background: #fff;
/*height: 50px;
width: 50px;*/
text-align: center;
vertical-align: middle;
border-radius: 8px;
display:inline-block;
font-size: 30px;
padding-top: 5px;
padding-right: 10px;
padding-bottom: 5px;
padding-left: 10px;
}
.waveButton:hover{
background: #f5faf9;
}
.waveButton:active{
background: #d9ebe9;
}
</style>
<div id="waveAppContainer">
<span class="waveButton" id="wave">👋 </span>
<span class="waveButton" id="thumbsUp" >👍 </span>
<span class="waveButton" id="thumbsDown">👎</span>
<span class="waveButton" id="raiseHand">✋ Raise Hand</span>
</div>
`;
document.body.appendChild(waveApp);
const waveButton = document.querySelector('#wave')
waveButton.addEventListener('click', function (e) {
sendEmoji("👋");
})
const thumbsUpButton = document.querySelector('#thumbsUp')
thumbsUpButton.addEventListener('click', function (e) {
sendEmoji("👍");
})
const thumbsDownButton = document.querySelector('#thumbsDown')
thumbsDownButton.addEventListener('click', function (e) {
sendEmoji("👎");
})
const raiseHandButton = document.querySelector('#raiseHand')
raiseHandButton.addEventListener('click', function (e) {
//document.querySelector("[aria-label='Chat with everyone']").click(); //Open chat sidebar
//The following code that gets the users name will only work if the sidebar was previously open.
setTimeout(() => { sendEmoji("✋ " + username + " raised their hand."); }, 500);
})
})();