-
Notifications
You must be signed in to change notification settings - Fork 0
/
content.js
36 lines (30 loc) · 1.08 KB
/
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
let attendees = {};
function updateAttendees() {
const elements = document.querySelectorAll('[data-self-name="You"], [data-participant-id]');
const currentTime = new Date().toISOString();
elements.forEach(el => {
const name = el.textContent.trim();
if (name) {
if (!attendees[name]) {
attendees[name] = { joinTime: currentTime, leftTime: null };
} else if (attendees[name].leftTime) {
attendees[name].leftTime = null; // They've rejoined
}
}
});
// Mark absent attendees as left
Object.keys(attendees).forEach(name => {
if (!Array.from(elements).some(el => el.textContent.trim() === name)) {
if (!attendees[name].leftTime) {
attendees[name].leftTime = currentTime;
}
}
});
chrome.storage.local.set({ attendees: attendees });
}
setInterval(updateAttendees, 5000); // Check every 5 seconds
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.action === "getAttendees") {
sendResponse({ attendees: Object.keys(attendees).filter(name => !attendees[name].leftTime) });
}
});