Skip to content

Instantly share code, notes, and snippets.

@monry
Last active September 16, 2018 15:36
Show Gist options
  • Save monry/1e28ee0fb0d42720bf0c22b9bfa11ac4 to your computer and use it in GitHub Desktop.
Save monry/1e28ee0fb0d42720bf0c22b9bfa11ac4 to your computer and use it in GitHub Desktop.
Copy workshop participations
var rows = 10;
var useDisplayName = true;
var typeMaps = [
{ type: '参加者', priority: 1, className: 'participation_table_area' },
{ type: '補欠者', priority: 2, className: 'waitlist_table_area' },
{ type: 'キャンセル', priority: 3, className: 'cancelled_table_area' },
];
var list = [];
for (let typeMap of typeMaps) {
$(`div.${typeMap.className} p.user_info`)
.each((index, u) => {
list.push({
typeMap: typeMap,
imageURL: $(u).find('img').attr('src'),
displayName: $(u).find('img').attr('alt'),
userName: $(u).find('span.user_name').text().replace(/^\((.*)\)$/, "$1"),
});
});
}
list = list.sort((a, b) => {
if (a.typeMap.priority > b.typeMap.priority) {
return 1;
}
if (a.typeMap.priority < b.typeMap.priority) {
return -1;
}
if (a.displayName.toLowerCase() > b.displayName.toLowerCase()) {
return 1;
}
if (a.displayName.toLowerCase() < b.displayName.toLowerCase()) {
return -1;
}
return 0;
});
var result = '';
for (var i = 0; i < Math.ceil(list.length / rows); i++) {
for (var j = 0; j < rows; j++) {
var index = i * rows + j;
if (list.length <= index) {
break;
}
if (j > 0) {
result += '\t';
}
result += ''; // Skip column for checkbox
result += '\t';
result += `=IMAGE("${list[index].imageURL}")`;
result += '\t';
result += useDisplayName ? list[index].displayName : list[index].userName;
}
result += '\n';
}
copy(result); // Copy result text into clipboard
@monry
Copy link
Author

monry commented Sep 16, 2018

Usege

  1. 某IT勉強会支援プラットフォームの勉強会参加者管理ページを開きます
  2. Chrome のデベロッパーコンソールを開きます
  3. このスクリプトをおもむろに貼り付けます
  4. クリップボードに 10列 × N行 の参加者リストがコピーされます
  5. Google SpreadSheet に貼り付けます
  6. A列, D列, G列…と、空セルがあるので、その空セルにチェックボックスを挿入します
  7. セル幅とかを良い感じに調整します

Customize

列数

  • スクリプトの1行目の数字を変更すれば列数を調整可能です
  • var rows = 1; とすれば直列な一覧表が作れます

出力するユーザ名を変更

  • デフォルトでは「表示名」を出力しています
  • 2行目の useDisplayName false にすれば某IT勉強会支援プラットフォーム上のユーザ名を出力可能です

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