Skip to content

Instantly share code, notes, and snippets.

@robfe
Created February 19, 2025 23:42
Show Gist options
  • Save robfe/fcb7f304fb49a9aeca4bcb028409e10e to your computer and use it in GitHub Desktop.
Save robfe/fcb7f304fb49a9aeca4bcb028409e10e to your computer and use it in GitHub Desktop.
var d = [];
var table = document.querySelector('table'); // make this selector more specific!
d.push([...table.querySelectorAll('thead>tr>th')].map(x=>x.innerText));
table.querySelectorAll('tbody>tr').forEach(r=>d.push([...r.querySelectorAll('td')].map(x=>x.innerText)));
var s = d.map(r=>r.map(JSON.stringify).join(',')).join('\n');
// copy(s); // copy to clipboard
window.open("data:text/csv;charset=utf-8,%EF%BB%BF"+encodeURI(s)); // download as CSV
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment