-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrowser-console.js
31 lines (22 loc) · 1.13 KB
/
browser-console.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
let previousParticipants = 0;
function checkParticipants() {
const participantList = document.querySelector('div[role="list"][aria-label="Participants"]');
if (!participantList) {
console.warn("Participant list not found.");
return;
}
// select only children of the participant list
const participantElements = participantList.querySelectorAll('[role="listitem"], [data-participant-id]');
// extract unique participant identifiers (fallback to innerText)
const participantIds = new Set([...participantElements].map(el => el.getAttribute('data-participant-id') || el.innerText || ''));
const participantCount = participantIds.size;
console.log(`Current number of participants: ${participantCount}`);
if (participantCount > previousParticipants) {
console.log('New participant joined');
fetch('http://localhost:5000/participant-joined')
.then(() => console.log('Participant joined event sent to server'))
.catch(err => console.error('Error notifying server:', err));
}
previousParticipants = participantCount;
}
setInterval(checkParticipants, 1000);