Skip to content

Instantly share code, notes, and snippets.

@soulim
Last active July 11, 2024 13:43
Show Gist options
  • Save soulim/daa27ea52ffc2ae3f9eb19d47aa0bdf0 to your computer and use it in GitHub Desktop.
Save soulim/daa27ea52ffc2ae3f9eb19d47aa0bdf0 to your computer and use it in GitHub Desktop.
Alex-o-Meter
(function () {
let elementGroups = document.querySelectorAll("div.VfPpkd-aGsRMb");
// console.log(elementGroups);
if (elementGroups.length == 0) {
alert("Error: cannot detect participant groups.\n\nOpen the people sidebar and try again. If it still doesn't work, check changes in CSS media queries.");
return;
}
let namesOnline = new Array();
elementGroups[0].querySelectorAll("div.VfPpkd-aGsRMb span.zWGUib").forEach((e) => { namesOnline.push(e.innerText); });
// console.log(namesOnline);
let namesOffline = new Array();
if (elementGroups[1] !== undefined) {
elementGroups[1].querySelectorAll("div.VfPpkd-aGsRMb span.zWGUib").forEach((e) => { namesOffline.push(e.innerText); });
}
// console.log(namesOffline);
let nameFilterFunc = (name) => {
const namePrefixes = [
"Alex",
"Aliaksa",
"Oleksa",
"Aleks"
];
let nameParts = name.split(" ");
return namePrefixes.find((prefix) => { return nameParts[0].startsWith(prefix); }) !== undefined;
};
let alexesOnline = new Array();
alexesOnline = namesOnline.filter(nameFilterFunc);
// console.log(alexesOnline);
let alexesOffline = new Array();
alexesOffline = namesOffline.filter(nameFilterFunc);
// console.log(alexesOffline);
let alexesOnlineRate = Math.floor(alexesOnline.length/namesOnline.length * 100);
// console.log(alexesOnlineRate);
if ((alexesOnline.length + alexesOffline.length) > 0) {
alert(`Alex-o-Meter\n\nOut of ${namesOnline.length} online people ${alexesOnlineRate}% are Alexes.`);
} else {
alert("This meeting is Alex free. Next time consider to invite at least one Alex!");
}
}());
@soulim
Copy link
Author

soulim commented Jul 10, 2024

A nice service to generate a bookmarklet: https://make-bookmarklets.com/.

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