-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstats.js
More file actions
34 lines (28 loc) · 850 Bytes
/
stats.js
File metadata and controls
34 lines (28 loc) · 850 Bytes
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
// stats.js
// Orchestrates loading of GitHub and Hackatime stats based on saved settings
(function () {
function getSettings() {
return JSON.parse(localStorage.getItem('settings')) || {};
}
function loadStats() {
const s = getSettings();
// Hackatime
if (s.hackatimeUsername && s.hackatimeKey && typeof window.refreshHackatime === 'function') {
window.refreshHackatime(s.hackatimeUsername, s.hackatimeKey);
}
// GitHub
if (s.githubUsername && typeof window.refreshGithub === 'function') {
window.refreshGithub(s.githubUsername);
}
}
// Run once DOM is ready
document.addEventListener('DOMContentLoaded', () => {
loadStats();
});
// Re-run whenever settings change
window.addEventListener('storage', (e) => {
if (e.key === 'settings') {
loadStats();
}
});
})();