Skip to content

Instantly share code, notes, and snippets.

@paulera
Last active November 4, 2020 10:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulera/e23462f76299f61e760a43140fc74f52 to your computer and use it in GitHub Desktop.
Save paulera/e23462f76299f61e760a43140fc74f52 to your computer and use it in GitHub Desktop.
Generate a list of participants, with check-in time
// 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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment