Skip to content

Instantly share code, notes, and snippets.

@kemsakurai
Forked from willnet/sample_from_atendees.js
Last active January 14, 2024 11:19
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 kemsakurai/69bb755724f2cc3e75b15d7b08a38de2 to your computer and use it in GitHub Desktop.
Save kemsakurai/69bb755724f2cc3e75b15d7b08a38de2 to your computer and use it in GitHub Desktop.
google meet参加者から誰か一人をランダムで選択するスクリプト|参加者をランダムにシャッフルするスクリプト
(function() {
let facilitator;
if (document.querySelector("[aria-label='参加者']")) {
const names_array = document.querySelector("[aria-label='参加者']").innerText.split("\n").filter((word) => !word.match(/\(|メイン|ミュート|主催者|あなたの画面共有|その他の操作|keep_off|more_vert|keep_pin|keep_pin_outline|domain_disabled/))
const names_set = new Set(names_array)
const names_uniq_array = Array.from(names_set)
facilitator = names_uniq_array[Math.floor(Math.random() * names_uniq_array.length)]
}
if (!facilitator) {
// chromeを利用して、ユーザ一覧を表示しつつconsoleで↓を実行すると、現在の参加者からランダムで一人表示することができます
let button = document.querySelector('[aria-label="全員を表示"]');
button.click();
// すぐに実行すると要素が取得できないので、1秒後に実行
setTimeout(() => {
const names_array = document.querySelector("[aria-label='参加者']").innerText.split("\n").filter((word) => !word.match(/\(|メイン|ミュート|主催者|あなたの画面共有|その他の操作|keep_off|more_vert|keep_pin|keep_pin_outline|domain_disabled/))
const names_set = new Set(names_array)
const names_uniq_array = Array.from(names_set)
facilitator = names_uniq_array[Math.floor(Math.random() * names_uniq_array.length)]
window.alert(facilitator);
const button = document.querySelector('[aria-label="全員を表示"]');
button.click();
}, 1000);
} else {
window.alert(facilitator);
}
})();
(function() {
let shuffle = (array) => {
return array.slice().sort(() => Math.random() - 0.5);
}
let shuffledArray;
if (document.querySelector("[aria-label='参加者']")) {
const names_array = document.querySelector("[aria-label='参加者']").innerText.split("\n").filter((word) => !word.match(/\(|メイン|ミュート|主催者|あなたの画面共有|その他の操作|keep_off|more_vert|keep_pin|keep_pin_outline|domain_disabled/))
const names_set = new Set(names_array)
const names_uniq_array = Array.from(names_set)
shuffledArray = shuffle(names_uniq_array)
}
if (!shuffledArray || shuffledArray.length == 0) {
// chromeを利用して、ユーザ一覧を表示しつつconsoleで↓を実行すると、現在の参加者からランダムで一人表示することができます
let button = document.querySelector('[aria-label="全員を表示"]');
button.click();
// すぐに実行すると要素が取得できないので、1秒後に実行
setTimeout(() => {
const names_array = document.querySelector("[aria-label='参加者']").innerText.split("\n").filter((word) => !word.match(/\(|メイン|ミュート|主催者|あなたの画面共有|その他の操作|keep_off|more_vert|keep_pin|keep_pin_outline|domain_disabled/))
const names_set = new Set(names_array)
const names_uniq_array = Array.from(names_set)
shuffledArray = shuffle(names_uniq_array)
window.alert(shuffledArray.join("\r\n"));
const button = document.querySelector('[aria-label="全員を表示"]');
button.click();
}, 1000);
} else {
window.alert(shuffledArray.join("\r\n"));
}
})();
// ==UserScript==
// @name Google Meet の参加者リストをシャッフルして取得する
// @namespace http://tampermonkey.net/
// @version 2024-01-14
// @description try to take over the world!
// @author You
// @match https://meet.google.com/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant GM_setClipboard
// ==/UserScript==
(function () {
'use strict';
document.addEventListener('keydown', function (e) {
if (e.ctrlKey && e.key === 'l') {
//e.preventDefault();
let e, r = e => e.slice().sort((() => Math.random() - .5));
if (document.querySelector("[aria-label='参加者']")) {
const t = document.querySelector("[aria-label='参加者']").innerText.split("\n").filter((e => !e.match(/\(|メイン|ミュート|主催者|あなたの画面共有|その他の操作|keep_off|more_vert|keep_pin|keep_pin_outline|domain_disabled/))),
n = new Set(t),
i = Array.from(n);
e = r(i)
}
if (e && 0 != e.length) GM_setClipboard(e.join("\r\n")), window.alert("clipboardにシャッフルした参加者リストをコピーしました。");
else {
document.querySelector('[aria-label="全員を表示"]').click(), setTimeout((() => {
const t = document.querySelector("[aria-label='参加者']").innerText.split("\n").filter((e => !e.match(/\(|メイン|ミュート|主催者|あなたの画面共有|その他の操作|keep_off|more_vert|keep_pin|keep_pin_outline|domain_disabled/))),
n = new Set(t),
i = Array.from(n);
e = r(i), GM_setClipboard(e.join("\r\n")), window.alert("clipboardにシャッフルした参加者リストをコピーしました。");
document.querySelector('[aria-label="全員を表示"]').click()
}), 1e3)
}
}
})
})();
@kemsakurai
Copy link
Author

kemsakurai commented Dec 19, 2023

  • ランダムに1名選択をブックマークレット化
javascript:!function(){let e;if(document.querySelector("[aria-label='参加者']")){const t=document.querySelector("[aria-label='参加者']").innerText.split("\n").filter((e=>!e.match(/\(|メイン|ミュート|主催者|あなたの画面共有|その他の操作|keep_off|more_vert|keep_pin|keep_pin_outline|domain_disabled/))),r=new Set(t),l=Array.from(r);e=l[Math.floor(Math.random()*l.length)]}if(e)window.alert(e);else{document.querySelector('[aria-label="全員を表示"]').click(),setTimeout((()=>{const t=document.querySelector("[aria-label='参加者']").innerText.split("\n").filter((e=>!e.match(/\(|メイン|ミュート|主催者|あなたの画面共有|その他の操作|keep_off|more_vert|keep_pin|keep_pin_outline|domain_disabled/))),r=new Set(t),l=Array.from(r);e=l[Math.floor(Math.random()*l.length)],window.alert(e);document.querySelector('[aria-label="全員を表示"]').click()}),1e3)}}();void(0);

@kemsakurai
Copy link
Author

kemsakurai commented Dec 19, 2023

  • シャッフルをブックマークレット化
javascript:!function(){let e,r=e=>e.slice().sort((()=>Math.random()-.5));if(document.querySelector("[aria-label='参加者']")){const t=document.querySelector("[aria-label='参加者']").innerText.split("\n").filter((e=>!e.match(/\(|メイン|ミュート|主催者|あなたの画面共有|その他の操作|keep_off|more_vert|keep_pin|keep_pin_outline|domain_disabled/))),n=new Set(t),i=Array.from(n);e=r(i)}if(e&&0!=e.length)window.alert(e.join("\r\n"));else{document.querySelector('[aria-label="全員を表示"]').click(),setTimeout((()=>{const t=document.querySelector("[aria-label='参加者']").innerText.split("\n").filter((e=>!e.match(/\(|メイン|ミュート|主催者|あなたの画面共有|その他の操作|keep_off|more_vert|keep_pin|keep_pin_outline|domain_disabled/))),n=new Set(t),i=Array.from(n);e=r(i),window.alert(e.join("\r\n"));document.querySelector('[aria-label="全員を表示"]').click()}),1e3)}}();void(0);```

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