Skip to content

Instantly share code, notes, and snippets.

@slashinfty
Last active April 21, 2020 03:00
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 slashinfty/522ba1d6e4ecb2fb5b026c34310bda57 to your computer and use it in GitHub Desktop.
Save slashinfty/522ba1d6e4ecb2fb5b026c34310bda57 to your computer and use it in GitHub Desktop.
Get a list of users who have sent a chat message in a Google Meet
// To run (in Chrome):
// MUST HAVE GOOGLE MEET CHAT VISIBLE!
// Press F12 to open Developer Tools
// Click the "Console" tab
// Copy and paste the code below
function copyToClipboard(str) {
var tempInput = document.createElement("input");
tempInput.style = "position: absolute; left: -1000px; top: -1000px";
tempInput.value = str;
document.body.appendChild(tempInput);
tempInput.select();
document.execCommand("copy");
document.body.removeChild(tempInput);
}
//find the chat element
var list = document.querySelectorAll('[aria-live="polite"]');
//find the messages
var messages = list[0].querySelectorAll('div');
var names = [];
messages.forEach(msg => {
//get names from elements
let name = (/(^.*?[a-zA-z])\d/).exec(msg.textContent);
//if it's a name you haven't had before, add it to the list
if (name !== null && name[1] !== null && !names.includes(name[1])) names.push(name[1]);
});
names.forEach((name, i) => {
//remove names that aren't names; also you
if (!(/^(\b[A-Z][\w\']*\s*)+$/).test(name) || name === "You") names.splice(i, 1);
});
let namesAsString = '';
//make it a list instead of an array
names.forEach((n, i) => namesAsString = i === 0 ? n : namesAsString + ', ' + n);
//copy list to your clipboard
copyToClipboard(namesAsString);
//now you can paste it where you want
@slashinfty
Copy link
Author

If you are so bold, you can create a bookmark and paste the following as the page (name can be whatever you want):

javascript:(function(){function copyToClipboard(e){var t=document.createElement("input");t.style="position: absolute; left: -1000px; top: -1000px",t.value=e,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}var list=document.querySelectorAll('[aria-live="polite"]'),messages=list[0].querySelectorAll("div"),names=[];messages.forEach(e=>{let t=/(^.*?[a-zA-z])\d/.exec(e.textContent);null===t||null===t[1]||names.includes(t[1])||names.push(t[1])}),names.forEach((e,t)=>{/^(\b[A-Z][\w\']*\s*)+$/.test(e)&&"You"!==e||names.splice(t,1)});let namesAsString="";names.forEach((e,t)=>namesAsString=0===t?e:namesAsString+", "+e),copyToClipboard(namesAsString);})();

Then, if you click the bookmark while a Google Meet chat is open, it'll automatically copy the names to your clipboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment