use setTimeout and enhance the meeting checking logic

This commit is contained in:
Rohid
2024-08-27 10:56:30 +06:00
parent fcb807f276
commit 652abc9c6f

View File

@@ -108,11 +108,30 @@ chrome.runtime.onMessage.addListener((request: { message: string }, sender, send
// https://meet.google.com/jzf-bwrz-djk // https://meet.google.com/jzf-bwrz-djk
if (window.location.href.startsWith('https://meet.google.com/')) { if (window.location.href.startsWith('https://meet.google.com/')) {
// In google meet website // In google meet website
// Check every two seconds if the user is in a meeting.
setInterval(() => { let inMeeting = false;
const inMeeting = !!document.querySelector('[data-meeting-title]');
if (inMeeting) { const checkIfInAMeeting = (ms: number) => {
debounce(() => init()); setTimeout(() => {
} const isMeetingPage = !!document.querySelector('[data-meeting-title]');
}, 2000);
if (isMeetingPage) {
void init();
inMeeting = true;
// If already in a meeting then check again after 2min
checkIfInAMeeting(1000 * 60 * 2);
} else {
if (inMeeting) {
void init();
inMeeting = false;
}
// If not in a meeting then check again after 5s
checkIfInAMeeting(1000 * 5);
}
}, ms);
};
checkIfInAMeeting(0);
} }