-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfocus.js
executable file
·36 lines (33 loc) · 1.08 KB
/
focus.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
let participants = [];
let participantIds = [];
let participantNames = [];
let nameToId = {};
let idToName = {};
const update = () => {
participants = Array.from(
document.getElementsByClassName('display-video')
);
participantIds = participants.map(p => p.id);
participantNames = participants.map(p =>
document.getElementById(p.id + '_name').innerHTML.replace("'s screen", '')
);
for (let i = 0; i < participants.length; i++) {
const name = participantNames[i].toLowerCase();
const id = participantIds[i];
nameToId[name] = id;
idToName[id] = name;
}
};
const getCurrentFocus = () => {
update();
const id = participants.filter(e => Array.from(e.classList).includes('videoContainerFocused'))[0].id;
const name = idToName[id];
return [ name, participantNames.map(name => name.toLowerCase()) ];
};
const focus = _name => {
const name = _name.toLowerCase();
const currentSpeakerName = getCurrentFocus()[0];
if (name !== currentSpeakerName) {
document.getElementById(nameToId[name]).click();
}
};