Last active
August 29, 2022 09:18
-
-
Save YOwatari/2527c83f721aa0226883260ec4641b7d to your computer and use it in GitHub Desktop.
LastPassの共有フォルダのメンバーをcsvで引っ張ってくる
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 table = document.querySelector('table.settings'); | |
const settingsRow = Array.from(table.querySelectorAll('tr.settingsRow')); | |
const folderName = document.querySelector('#sharedFolderDialogTitle').innerText.replace('Manage Shared Folder: ', '') ; | |
const rows = settingsRow.map(tr => { | |
const row = []; | |
row.push(folderName); | |
tr.querySelectorAll('td').forEach(td => { | |
if (td.className == 'name') { | |
row.push(td.innerText); | |
} | |
if (td.className == 'readonly' || td.className == 'can_administer') { | |
row.push(td.querySelector('input.checkbox').checked); | |
} | |
}) | |
return row; | |
}).filter(v => v[1] != ''); | |
const csv = rows.map(row => row.map(v => `"${v}"`)).join("\n"); | |
const f = new Blob([csv], { type: 'text/csv' }); | |
const a = document.createElement('a'); | |
a.style.display = 'none'; | |
a.download = folderName + '.csv'; | |
a.href = URL.createObjectURL(f); | |
document.body.appendChild(a); | |
a.click(); | |
document.body.removeChild(a); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment