-
-
Save soulim/daa27ea52ffc2ae3f9eb19d47aa0bdf0 to your computer and use it in GitHub Desktop.
Alex-o-Meter
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
(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!"); | |
} | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A nice service to generate a bookmarklet: https://make-bookmarklets.com/.