Last active
November 27, 2022 17:22
Automatically turns off mic and camera, joins the call, admits new people, and sends notification on new chat messages on Google Meet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Google Meet enhancer | |
// @description Automatically turns off mic and camera, joins the call, admits new people, and sends notification on new chat messages | |
// @namespace https://github.com/SergiusGit | |
// @homepageURL https://github.com/SergiusGit | |
// @supportURL https://gist.github.com/SergiusGit/6803baefa0cd83de5cfd1015d4107a41/ | |
// @updateURL https://gist.github.com/SergiusGit/6803baefa0cd83de5cfd1015d4107a41/raw/google-meet-enhancer.user.js | |
// @downloadURL https://gist.github.com/SergiusGit/6803baefa0cd83de5cfd1015d4107a41/raw/google-meet-enhancer.user.js | |
// @match https://meet.google.com/* | |
// @icon https://static.wikia.nocookie.net/logopedia/images/5/56/GoogleMeet_2020.svg/revision/latest/scale-to-width-down/200 | |
// @grant none | |
// @version 1.0.5 | |
// @author Sergius | |
// @license MIT | |
// @run-at document-end | |
// ==/UserScript== | |
(() => { | |
const autoMuteMicAndCam = true; | |
const autoJoin = true; | |
const autoAdmit = true; | |
const sendChatNotifications = true; | |
const turnSubsOn = true; | |
function muteAll() { | |
const loadInterval = setInterval(() => { | |
const btns = document.querySelectorAll("[data-is-muted=false][role]"); | |
if (btns.length) { | |
btns.forEach((btn) => btn.click()); | |
clearInterval(loadInterval); | |
} | |
}, 100); | |
} | |
function askToJoin() { | |
const joinInterval = setInterval(() => { | |
const progress = document.querySelector(".VfPpkd-JGcpL-P1ekSe-OWXEXe-A9y3zc"); | |
if (!progress) { | |
const btn = document.querySelector(".VfPpkd-LgbsSe-OWXEXe-k8QpJ"); | |
if (btn) { | |
btn.click(); | |
clearInterval(joinInterval); | |
} | |
} | |
}, 100); | |
} | |
function admitAll() { | |
setInterval(() => { | |
const spans = document.getElementsByTagName("span"); | |
for (const span of spans) { | |
if (span.innerText === "Admit" || span.innerText === "View all") { | |
span.click(); | |
} | |
} | |
}, 1000); | |
} | |
function askNotificationPermission() { | |
if (!("Notification" in window)) { | |
return; | |
} else if (Notification.permission === "granted") { | |
observeChat(); | |
} else if (Notification.permission !== "denied") { | |
Notification.requestPermission().then((permission) => { | |
if (permission === "granted") { | |
observeChat(); | |
} | |
}); | |
} | |
} | |
function observeChat() { | |
const intervalID = setInterval(() => { | |
const chatIcon = document.querySelector("button[aria-label='Chat with everyone']"); | |
if (chatIcon) { | |
clearInterval(intervalID); | |
chatIcon.click(); | |
const chatWait = setInterval(() => { | |
const chat = document.querySelector(".z38b6"); | |
if (chat) { | |
clearInterval(chatWait); | |
new MutationObserver((list) => { | |
const node = list[list.length - 1].addedNodes[0]; | |
const msgSender = | |
node.getAttribute("data-sender-name") || | |
node.parentNode.parentNode.getAttribute("data-sender-name"); | |
const msgText = node.classList.contains("oIy2qc") | |
? node.innerText | |
: node.childNodes[1].childNodes[ | |
node.childNodes[1].childNodes.length - 1 | |
].innerText; | |
if (msgSender !== "You") { | |
new Notification(msgSender, { | |
body: msgText, | |
renotify: true, | |
icon: "https://static.wikia.nocookie.net/logopedia/images/5/56/GoogleMeet_2020.svg/revision/latest/scale-to-width-down/200", | |
}); | |
} | |
}).observe(chat, { childList: true, subtree: true }); | |
setTimeout(() => { | |
chatIcon.click(); | |
}, 500); | |
} | |
}, 100); | |
} | |
}, 1000); | |
} | |
function turnSubtitlesOnOnJoin() { | |
const intervalID = setInterval(() => { | |
const subsIcon = document.querySelector("button[aria-label='Turn on captions (c)']"); | |
if (subsIcon) { | |
clearInterval(intervalID); | |
subsIcon.click(); | |
} | |
}, 1000); | |
} | |
if (autoMuteMicAndCam) { | |
muteAll(); | |
} | |
if (autoJoin) { | |
askToJoin(); | |
} | |
if (autoAdmit) { | |
admitAll(); | |
} | |
if (sendChatNotifications) { | |
askNotificationPermission(); | |
} | |
if (turnSubsOn) { | |
turnSubtitlesOnOnJoin(); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment