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
|
// run this in the console
// call copyAttendanceListToClipboard() in the console to get the list.
function initializeAttendanceList() {
window.attendanceMap = new Map();
}
function computeParticipants() {
var elements = document.querySelectorAll("div[data-self-name]");
for (var item of elements) {
var name = item.innerHTML;
if (name != "You" && !window.attendanceMap.has(name)) {
var now = new Date().toLocaleTimeString([], { hour: '2-digit', minute: "2-digit", hour12: false });
window.attendanceMap.set (name, now);
console.log ("Attendance: " + name + " joined at " + now);
}
}
return window.attendanceMap;
}
function abortGetAttendance() {
if (window.attendanceListTimer) {
clearInterval(window.attendanceListTimer);
console.log ("Attendance timer killed");
}
window.attendanceListTimer = null;
}
function startComputeAttendance() {
if (window.attendanceListTimer) {
abortGetAttendance();
}
computeParticipants();
window.attendanceListTimer = setInterval (computeParticipants, 15000);
console.log ("Attendance timer started");
}
function renderAttendanceList() {
var attendanceList = "";
for (var item of window.attendanceMap) {
attendanceList += item[1] + "\t" + item[0] + "\n";
};
return attendanceList;
}
function copyAttendanceListToClipboard () {
navigator.clipboard.writeText(renderAttendanceList());
alert("Attendance list copied to the clipboard");
}
initializeAttendanceList();
startComputeAttendance();
|