-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlogtime.js
34 lines (34 loc) · 1.22 KB
/
logtime.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
const monthLabels = Array.from(document.querySelectorAll('svg text[font-size="10"]'));
const months = {};
let currentMonthLabel = null;
monthLabels.forEach(label => {
const monthName = label.textContent.trim();
months[monthName] = [];
currentMonthLabel = monthName;
});
const elements = document.querySelectorAll('svg text[font-size="10"], svg g[data-toggle="tooltip"][data-original-title]');
elements.forEach(element => {
const tagName = element.tagName.toLowerCase();
if (tagName === 'text') {
const monthName = element.textContent.trim();
currentMonthLabel = monthName;
} else if (tagName === 'g') {
if (currentMonthLabel !== null) {
months[currentMonthLabel].push(element);
}
}
});
const monthSums = {};
for (const monthName in months) {
monthSums[monthName] = 0;
months[monthName].forEach(element => {
const title = element.getAttribute('data-original-title');
const time = parseFloat(title.replace("h", "."));
if (!isNaN(time)) {
monthSums[monthName] += Math.floor(time);
monthSums[monthName] += (time - Math.floor(time)) / 6 * 10;
}
});
monthSums[monthName] = (monthSums[monthName] + ((monthSums[monthName] - Math.floor(monthSums[monthName])) * 0.6)).toFixed(2);
}
monthSums;