Skip to content

Instantly share code, notes, and snippets.

@rayriffy
Last active August 9, 2021 05:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rayriffy/8bdb79461e3d33b42029632fca45c4c2 to your computer and use it in GitHub Desktop.
Save rayriffy/8bdb79461e3d33b42029632fca45c4c2 to your computer and use it in GitHub Desktop.
let getAllNameInMeeting = () => Array.from(document.querySelector('calling-roster-section[data-tid=participantsInCall]').querySelectorAll('div.name > span')).map(o => o.textContent.toLowerCase())
let leaveIfSomeoneLeave = (name) => {
try {
const lowerCaseNames = getAllNameInMeeting()
// if not found, then leave
if (!lowerCaseNames.includes(name)) {
console.log(`[leaveIfSomeoneLeave] "${name}" is leaving! stopping the call`)
document.querySelector('#hangup-button').click()
} else {
console.log(`[leaveIfSomeoneLeave] ${lowerCaseNames.length} people in metting right now, found "${name}" in the list`)
}
} catch (e) {
// noop
}
}
let execute = (name, intervalTime = 1000) => {
const intervalId = setInterval(() => leaveIfSomeoneLeave(name), intervalTime)
const stop = () => clearInterval(intervalId)
return {
intervalId,
stop,
}
}
// let studentWorker = execute('someone', 10 * 1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment