Last active
January 11, 2024 02:05
-
-
Save kyletimmermans/ce1202f9c35ec45c2a14a9b212ae3b36 to your computer and use it in GitHub Desktop.
A script to automatically leave meetings / exit a webpage after a given amount of time
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
/* Run in your browser's JS console */ | |
MeetingExiter = () => { | |
// Don't allow it to be running more than once | |
if (typeof meetingExiterMutex !== "undefined") { | |
if (meetingExiterMutex === true) { | |
console.error("Cant't run more than 1 exiter job at a time!"); | |
return; | |
} else { | |
meetingExiterMutex = true; | |
} | |
} else { | |
meetingExiterMutex = true; // No var/let means global | |
} | |
var mins = prompt("How many minutes from now would you like to leave the meeting?"); | |
if (mins === null) { // Prompt 'Cancel' button clicked | |
meetingExiterMutex = false; | |
return; | |
} | |
if (isNaN(mins) || mins === '') { | |
meetingExiterMutex = false; | |
console.error("Minutes must be a number!"); | |
return; | |
} | |
var confirm = prompt("Are you sure you want to exit in "+mins+" minutes? (Y/n)"); | |
// Null check 1st, so regex doesnt have to deal with it | |
if (confirm === null || !confirm.match(/^[Yy]([Ee][Ss])?$/)) { | |
console.error("Job cancelled"); | |
meetingExiterMutex = false; | |
return; | |
} | |
// Prevent "Leave site?" alert box from stopping the exit | |
window.onbeforeunload = function(){}; | |
setTimeout(() => { | |
/* - /404 uses current host name so we avoid | |
X-Frame-Options sameorigin security error | |
- Don't use window.close() b/c you can get the error: | |
"Scripts may only close the windows that were opened by them" */ | |
window.location.replace("/404"); | |
}, mins*60000); // Every min is 60000ms (60 secs/min, 1000ms/sec) | |
console.clear(); // Clear other messages so its pretty | |
console.log("%cExiting meeting in "+mins+" minute(s)!", | |
"background: black; color: lime; font-size: 30px;"); | |
} | |
MeetingExiter(); // Call func |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment