Skip to content

Instantly share code, notes, and snippets.

@peh
Last active March 4, 2021 05:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peh/0504bb1ef28c206d2f4439ce0d7ed1cd to your computer and use it in GitHub Desktop.
Save peh/0504bb1ef28c206d2f4439ce0d7ed1cd to your computer and use it in GitHub Desktop.
Google Meet Autojoin
// ==UserScript==
// @name Google Meet Autojoin
// @version 0.0.2
// @description try to take over the world!
// @author Philipp Eschenbach
// @match https://meet.google.com/*
// @grant none
// ==/UserScript==
(function() {
if (~document.body.children[0].id.indexOf("error")) {
window.location.reload();
} else {
console.log("looks good")
}
setTimeout(() => {
/**
}
* Simulate a click event.
* @public
* @param {Element} elem the element to simulate a click on
*/
function simulateClick(elem) {
// Create our event (with options)
var evt = new MouseEvent('click', {
bubbles: true,
cancelable: true,
view: window
});
// If cancelled, don't dispatch our event
var canceled = !elem.dispatchEvent(evt);
}
const joinButton = Array.from(document.querySelectorAll('[role="button"]')).filter(el => el.textContent.toLowerCase().includes('join') || el.textContent.toLowerCase().includes('teilnahme'))[0];
setTimeout(() => {
simulateClick(joinButton);
}, Math.random()*2000);
}, 3000);
setInterval(() => {
const closeButton = Array.from(document.getElementsByTagName('span')).filter(el => el.textContent.toLowerCase().includes('return to'))[0];
if (closeButton) {
window.close()
}
}, Math.random()*1500)
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment