-
-
Save KiKiKi-KiKi/baf1c3d609925aa2f260371eb4edb569 to your computer and use it in GitHub Desktop.
🐰 Generate participants CSV from twipla.jp. Open dev tool console and copy & paste this script 👍
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
const listElement = '.member_list'; | |
const userElement = 'a.namelist'; | |
const getDate = () => { | |
const d = new Date(); | |
return `${d.getFullYear()}-${d.getMonth()}-${d.getDay()}-${d.getTime()}`; | |
} | |
const getUserData = (elm) => { | |
const twitterID = elm.getAttribute('title'); | |
return [ | |
elm.getAttribute('n'), | |
twitterID, | |
`https://twitter.com/${twitterID.replace('@', '')}` | |
]; | |
}; | |
const getUsersList = () => { | |
return [...document.querySelectorAll(listElement)].reduce((data, section) => { | |
return [ | |
...data, | |
[section.firstChild?.data], | |
...[...section.querySelectorAll(userElement)].map(getUserData), | |
] | |
}, []); | |
}; | |
const downloadCSV = (data) => { | |
const blob = new Blob([data.map(row => row.join(',')).join('\n')], {type: 'text/csv'}); | |
const fileName = `${document.title}_${getDate()}.csv`; | |
const url = (window.URL || window.webkitURL).createObjectURL(blob); | |
const link = document.createElement('a'); | |
link.download = fileName; | |
link.href = url; | |
document.body.appendChild(link); | |
link.click(); | |
document.body.removeChild(link); | |
}; | |
!(() => { | |
const header = ['userName', 'twitterId', 'twitterLink']; | |
downloadCSV([ | |
header, | |
...getUsersList(), | |
]) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🎉 TwiPla (twipla.jp) のイベントページから 参加者, 興味あり, 不参加 のユーザーリストを CSV としてダウンロードできるスクリプトです。
🌟 How to use
ファイル名は
TwiPla のタイトル_YYYY-M-D-timestamp.csv
で出力されます。HTML からマッシュアップしているので TwiPla の DOM 構成やクラス名が変更になる動作しなくなります。
動作確認は Chrome v.88.0.4324.192 でしかしていません