-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathattendance.js
142 lines (117 loc) · 5.03 KB
/
attendance.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
let meetActionButtons;
let participantsList = new Set();
let attendanceData = new Map();
let meetDuration = 0;
let participantsButtonIndex = 1;
let startTime = new Date().toLocaleTimeString();
function track_attendance() {
let currentParticipants = document.getElementsByClassName("KjWwNd");
let currentParticipantsName = document.getElementsByClassName("zWGUib");
if (currentParticipants.length > 0) {
participantsList.clear();
for (i = 0; i < currentParticipants.length; i++) {
participantsList.add({
identifier: currentParticipants[i].src,
name: currentParticipantsName[i].innerHTML.toUpperCase()
});
}
participantsList.forEach(function(key, participant) {
if (attendanceData.has(participant.identifier)) {
let data = attendanceData.get(participant.identifier);
data.attendedDuration += 1;
data.attendance.push(1);
attendanceData.set(participant.identifier, data);
} else {
let joinTime = new Date().toLocaleTimeString();
let attendance = [];
for (j = 0; j < meetDuration; j++) { attendance.push(0); }
attendance.push(1);
let data = {
name: participant.name,
joinTime: joinTime,
attendedDuration: 1,
attendance: attendance
};
attendanceData.set(participant.identifier, data);
}
});
attendanceData.forEach(function(data, identifier) {
if (data.attendance.length != (meetDuration + 1)) {
data.attendance.push(0);
}
});
meetDuration += 1;
chrome.storage.sync.set({report:attendanceData}, function() {
console.log('Attendance saved for');
});
console.log("hi")
console.log(attendanceData)
} else {
try {
meetActionButtons[participantsButtonIndex].click();
} catch (error) {
stop();
}
}
}
function start() {
tracking = setInterval(track_attendance, 1000);
}
let stop = STOP = function() {
clearInterval(tracking);
let meetCode = window.location.pathname.substring(1);
let date = new Date();
let dd = date.getDate();
let mm = date.toLocaleString('default', { month: 'short' });
let yyyy = date.getFullYear();
let uuid = meetCode + dd + date.getMonth() + yyyy + date.getHours() + date.getMinutes() + date.getSeconds() + date.getMilliseconds();
date = dd + '/' + mm + "/" + yyyy;
var attendanceDetails = {
meetCode: meetCode,
date: date,
startTime: startTime,
stopTime: new Date().toLocaleTimeString(),
participants: Object.fromEntries(attendanceData),
meetDuration: meetDuration
}
attendanceReport = {}
attendanceReport[uuid] = attendanceDetails
}
/*
---------------------------------------------------
Update ui of google meet to support extra features.
---------------------------------------------------
*/
// Status text
let statusText = document.createElement("button");
statusText.id = "status";
statusText.className = "Jyj1Td CkXZgc";
statusText.innerHTML = " 🔴 Meet Attendance Tracker";
statusText.style.color = "red";
statusText.style.fontWeight = "bold";
statusText.style.padding = "auto";
statusText.style.border = "none";
statusText.style.outline = "none";
statusText.style.background = "transparent";
const blinkSpeed = 500;
setInterval(function() { statusText.style.visibility = (statusText.style.visibility == 'hidden' ? '' : 'hidden'); }, blinkSpeed);
// Action window
// var logoUrl = 'https://trackitnow.pythonanywhere.com/static/mac/images/mac-logo.png';
// let actionButtonDiv = document.createElement('div');
// actionButtonDiv.className = 'r6xAKc';
// actionButtonDiv.innerHTML = '<button class="VfPpkd-Bz112c-LgbsSe yHy1rc eT1oJ JsuyRc boDUxc" jscontroller="soHxf" jsaction="click:cOuCgd; mousedown:UX7yZ; mouseup:lbsD7e; mouseenter:tfO1Yc; mouseleave:JywGue; touchstart:p6p2H; touchmove:FwuNnf; touchend:yfqBxc; touchcancel:JMtRjd; focus:AHmuwe; blur:O22p3e; contextmenu:mg9Pef;mlnRJb:fLiPzd" jsname="A5il2e" data-disable-idom="true" aria-label="Notes" data-tooltip-enabled="true" data-tooltip-id="tt-c21" aria-pressed="false" data-panel-id="1" data-promo-anchor-id="GEUYHe"><div jsname="s3Eaab" class="VfPpkd-Bz112c-Jh9lGc"></div><img class="google-material-icons VfPpkd-kBDsod" aria-hidden="true" src="' + logoUrl + '"></button>';
/*
-------------------
start the extension
-------------------
*/
let engine = setInterval(startEngine, 1000);
function startEngine() {
try {
meetActionButtons = document.getElementsByClassName("VfPpkd-kBDsod NtU4hc");
document.getElementsByClassName("Qp8KI")[0].appendChild(statusText);
document.getElementsByClassName("SGP0hd kunNie")[0].appendChild(actionButtonDiv);
start();
clearInterval(engine);
} catch (error) {}
};