-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
27 lines (23 loc) · 817 Bytes
/
Copy pathbackground.js
File metadata and controls
27 lines (23 loc) · 817 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
let pageLoadTime = null;
function measurePageLoadTime() {
if (window.performance) {
const timing = window.performance.timing;
if (timing.navigationStart > 0 && timing.loadEventEnd > 0) {
pageLoadTime = timing.loadEventEnd - timing.navigationStart;
console.log(pageLoadTime);
} else {
// Performance timing data is not available
pageLoadTime = null;
}
} else {
// The browser doesn't support the window.performance API
pageLoadTime = null;
}
}
chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
if (message.action === 'getPageLoadTime') {
updateBadgeText(); // Update badge text when requested
sendResponse(pageLoadTime);
}
});
// Call the updateBadgeText function initially and periodically