Skip to content

Instantly share code, notes, and snippets.

@anweshandev
Last active July 21, 2022 02:32
Show Gist options
  • Save anweshandev/3c764c1dcb9d81532e1be359fc9cacbb to your computer and use it in GitHub Desktop.
Save anweshandev/3c764c1dcb9d81532e1be359fc9cacbb to your computer and use it in GitHub Desktop.
Automating Google Meet

Automating Google Meet

Ever wanted to automatically "Join", "Admit People", and then "Automatically Leave (or End the call)". I wanted one, could not find one which suits my taste and hence I compiled this application. Have a read below.

Case Study:

I developed this code solely because my mother is a teacher. As the pandemic is raging, her school started taking online classes. If I assume every class has around 40 students at an average and she takes at least 6 periods a day, thats around 6 x 40 = 240 students at an average. If she teaches from a Tablet or a Laptop, she has to admit students after students. If around an average of 7 to 10 comes in a bunch at the very begining, then for every class it's 40 - 10 = 30 clicks on an average. For 6 periods, that's aroung 180 clicks a day. For 5 days in a week for 4 weeks i.e. aroung 180 * 20 clicks = 3600 clicks per month at the same location for a tablet on the screen or via a trackpad. Just think about the trackpad or mouse clicking noise, that alone will keep you awake all night. Worst Case Scenario Google Meet from mobile, and single clicks for each 40 students, 6 times a day, 5 days a week and for 4 weeks.

Missing Feature:

Unlike Zoom, Google Meet has no option of disabling the waiting room (or lobby).

Alternative Solution:

One can always schedule a meeting from Google Calendar and paste all the email-address(es) as invitees. The only disadvantage being any one can join before the host (atleast 15 minutes before) and misuse the platform or keep chatting. To disable this you can see Foot Note option @@.

Few Observations:

Google for all it's used now has host options with the following features:

  1. Turn off video for all.
  2. Turn off microphone for all.
  3. Revoke permission for share screen.
  4. Revoke permission for in-call messages (chat).
  5. Gives option for End meeting for all or Leave Meeting, when hangup button is pressed.

💡 The code below assumes a Google Workspace User as host of meeting, with active hand-raise# ✋ feature. Some additional features are not listed here and can be found at footnote @.

The code

Refer index.js below.

Features of our code

  1. Automatically join google meet by pressing the "JOIN" button itself at your preferred time.
  2. Automatically admit people in the waiting room by pressing "Admit All" or "Admit" from preferred time.
  3. If you want to stop auto-admit of people in waiting room from a certain time, you may do so at your prefered time.
  4. Automatically leave (or end the call), by pressing hangup at a preferred time.
  5. Lowering the hand# (forcefully or automatically).

How to make it work?

  1. Open Developer Console (DevTools), either by pressing F12, or Ctrl + Shift + I or on Mac Cmd + Opt + I.
  2. Copy paste the code in the developers console.
  3. Call the function google_meet_function with the appropiate arguments.

Documentation.

A comprehensive documentation is given below. Please also read the footnotes to understand any cross-references.

Argument(s) Documentation

  1. join_time_arr1: The variable controls the joining time from joining page. The significant JOIN NOW is clicked. Refer to contents of Schema 1.

  2. admit_time_arr2: The variable controls the time from when the auto-admit feature should be started ✅. The algorithm auto-detects Admit All or Admit as and when presented and clicks the same. Refer to contents of Schema 1.

  3. pause_admit_time_arr3: The variable controls the time after which no auto-admit (if enabled) will function. Refer to contents of Schema 1.

  4. leave_meeting_time_arr4: The variable controls the time to exit the Google Meet Session, by clicking the hangup button. As this gives two options the scenarios are explained: - Clicking End the class: If the parameter force_leave is true, the same option is clicked. - Clickng Just Leave the call: If the parameter force_leave is false, the same option is clicked. Refer to contents of Schema 1.

  5. force_leave: The variable controls which option to click after hangup is clicked. Refer above to documentation provided at leave_meeting_time_arr4. The variable is itself of type boolean accepting either true or false.

  6. leave_latency: This is an integer and it actually the count of the number of seconds to wait before Ending the call or Just leaving the call as set by the force_leave parameter.

  7. lower_hand#: If true all hands (including the host(s)) will be lowered.

Variable Schema:

  • Schema 1:
    • Variable Type: array[]
    • Contents:
      • HH for hours.
      • MM for minutes.
      • SS for seconds.
    • @throws:
      • If HH is missing, an error is raised.
      • If either of HH or MM or SS is/are negative (i.e. less than 0), then NegativeNumberError is raised.

Thoughts

Google can solve this problem, just by one addition, a button which toggles off to disable the lobby. This is an open source code. I am eager to see people make use of it and extend it.

Footnote

  1. @ Few features are available for Google Workspace Users like Breakout Rooms, Polls, Hand Raise, Recording, Ask a Question & Assigning a Co-Host.
  2. @@ A feature for paid users are available in Google Calendar & Host Controls of Google Meet, where you can turn off Quick Access, to restrict users to see or interact with each other before the host joins.
  3. # To lower hand, please keep the side panel open.
let clicked = false;
function google_meet_function(join_time_arr1 = null, admit_time_arr2 = null, pause_admit_time_arr3 = null, leave_meeting_time_arr4 = null, lower_hand = true, force_leave = true, leave_latency = 8) {
const now = new Date();
const special_class = ".RveJvd.snByac";
let join_time_1 = null;
if (join_time_arr1 != null) {
join_time_1 = new Date(now.getFullYear(), now.getMonth(), now.getDate(), join_time_arr1[0], join_time_arr1[1] || now.getMinutes(), join_time_arr1[2] || now.getSeconds(), 0) - now;
}
let y = null;
let join_time_3 = null;
let join_time_2 = null;
let join_time_4 = null;
let auto_admit = null;
if (admit_time_arr2 != null) {
join_time_2 = new Date(now.getFullYear(), now.getMonth(), now.getDate(), admit_time_arr2[0], admit_time_arr2[1] || now.getMinutes(), admit_time_arr2[2] || now.getSeconds(), 0) - now;
}
if (pause_admit_time_arr3 != null) {
join_time_3 = new Date(now.getFullYear(), now.getMonth(), now.getDate(), pause_admit_time_arr3[0], pause_admit_time_arr3[1] || now.getMinutes(), pause_admit_time_arr3[2] || now.getSeconds(), 0) - now;
}
if (leave_meeting_time_arr4 != null) {
join_time_4 = new Date(now.getFullYear(), now.getMonth(), now.getDate(), leave_meeting_time_arr4[0], leave_meeting_time_arr4[1] || now.getMinutes(), leave_meeting_time_arr4[2] || now.getSeconds(), 0) - now;
}
let dismiss = setInterval(function() {
for (let item of document.querySelectorAll(special_class)) {
if (item.innerText == "Dismiss") {
item.click();
}
}
}, 1000);
if (join_time_1 != null && join_time_1 > 0) {
setTimeout(function() {
for (let item of document.getElementsByTagName("span")) {
if (item.innerText == "Join now") {
item.click();
}
setTimeout(() => {
let everyone = document.querySelector("[aria-label='Show everyone']");
if (everyone) {
everyone.click();
}
}, 5000);
}
}, join_time_1);
}
if (join_time_2 != null && join_time_2 > 0) {
setTimeout(function() {
auto_admit = setInterval(function() {
for (let item of document.querySelectorAll(special_class)) {
if (item.innerText == "View all" || item.innerText == "Admit all" || item.innerText == "Admit")
item.click();
}
}, 100);
}, join_time_2);
}
if (lower_hand == true) {
setInterval(function() {
let low = document.querySelector("[aria-label='Lower all']");
if (low != null) {
low.click();
}
}, 100);
}
if (join_time_3 != null && join_time_3 > 0) {
// After this time, we need to clear auto admit. So, we need to activate
// hand down manually.
setTimeout(function() {
if (auto_admit) {
// We have cleared off our auto_admit procedure.
clearInterval(auto_admit);
}
}, join_time_3);
}
if (join_time_4 != null) {
setTimeout(function() {
for (let item of document.querySelectorAll("button")) {
if (item.hasAttribute("aria-label") && item.getAttribute("aria-label") == "Leave call") {
item.addEventListener("click", function(e) {
// Updated code -
setTimeout(function() {
let end_call = null;
if (force_leave) end_call = document.querySelector("[aria-label='End the call']");
else end_call = document.querySelector("[aria-label='Just leave the call']");
if (end_call != null) {
end_call.click();
}
}, leave_latency * 1000);
});
if (!clicked) {
item.click();
clicked = true;
}
break;
}
}
}, join_time_4);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment