Skip to content

Instantly share code, notes, and snippets.

@joaofnds
Created May 5, 2019 23:18
Show Gist options
  • Select an option

  • Save joaofnds/c7d3fe41bd4ec2ec5c2a7c49d00b82f4 to your computer and use it in GitHub Desktop.

Select an option

Save joaofnds/c7d3fe41bd4ec2ec5c2a7c49d00b82f4 to your computer and use it in GitHub Desktop.
Gets links from pocket exported HTML file, organized by tags.
const pocketData = Array.from(document.querySelectorAll('a'))
.map(a => {
return {
name: a.innerText,
link: a.getAttribute('href'),
tags: a.getAttribute('tags').split(',').filter(t => t.length != 0)
}
})
.reduce((tags, entry) => {
if (entry.tags.length == 0) {
tags.untagged.push(entry)
} else {
entry.tags.forEach(tag => {
if (tags[tag] == undefined) tags[tag] = []
tags[tag].push(entry)
})
}
return tags
}, { untagged: [] })
console.log(pocketData)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment