Skip to content

Instantly share code, notes, and snippets.

@gregtatum
Created May 19, 2020 17:28
Show Gist options
  • Save gregtatum/9ed49ac5cc718b7c90658c6575babeb4 to your computer and use it in GitHub Desktop.
Save gregtatum/9ed49ac5cc718b7c90658c6575babeb4 to your computer and use it in GitHub Desktop.
// https://tcchd.maps.arcgis.com/apps/opsdashboard/index.html#/ebb119cd215b4c57933b7fbe477e7c30
// ​[fill="#ffaa00"]
// [aria-label="Cases Mar 23, 2020 23"]
const caseFill = "#ffaa00";
{
const data = $$("[aria-label]")
.filter(el => el.getAttribute("fill") === caseFill)
.map(el => el.getAttribute("aria-label"))
.map(label => label.match(/^Cases (\w+ \d+, \d+) (\d+)/))
.filter(n => n)
.map(([_, dateString, count]) => {
const date = new Date(dateString)
const year = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(date)
const month = new Intl.DateTimeFormat('en', { month: 'short' }).format(date)
const day = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(date)
return `${year}-${month}-${day}\t${count}`
})
const string = data
.sort()
.join('\n')
console.log(data)
copy(string)
}
// [fill="#a80000"]
// [aria-label="Deaths May 07, 2020 36"]
const deathFill = "#a80000";
{
const data = $$("[aria-label]")
.filter(el => el.getAttribute("fill") === deathFill)
.map(el => el.getAttribute("aria-label"))
.map(label => label.match(/^Deaths (\w+ \d+, \d+) (\d+)/))
.filter(n => n)
.map(([_, dateString, count]) => {
const date = new Date(dateString)
const year = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(date)
const month = new Intl.DateTimeFormat('en', { month: 'short' }).format(date)
const day = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(date)
return `${year}-${month}-${day}\t${count}`
})
const string = data
.sort()
.join('\n')
console.log(data)
copy(string)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment