News for hackers. Stuff that matters.
Re:Poll: Where do you live? by runjake on Friday February 04, 2022 @03:08PM (#30212295)
Neat!

Noob question: is there a similar way to dump it to JSON, instead of a table?

Re:Poll: Where do you live? by chair6 on Friday February 04, 2022 @03:12PM (#30212363)
Just replace console.table with JSON.stringify for the quick-and-easy dump of exactly the same data as is in the table...

JSON.stringify([...document.querySelectorAll('.fatitem table .athing')].map(el => [el.textContent.trim(), el.nextSibling.textContent.trim()]).sort(([,a], [,b]) => parseInt(b) - parseInt(a)))

Re:Poll: Where do you live? by AntonyGarand on Friday February 04, 2022 @03:12PM (#30212375)
Replace `console.table` with `JSON.stringify`:

JSON.stringify([...document.querySelectorAll('.fatitem table .athing')].map(el => [el.textContent.trim(), el.nextSibling.textContent.trim()]).sort(([,a], [,b]) => parseInt(b) - parseInt(a)))