Created
May 5, 2019 23:18
-
-
Save joaofnds/c7d3fe41bd4ec2ec5c2a7c49d00b82f4 to your computer and use it in GitHub Desktop.
Gets links from pocket exported HTML file, organized by tags.
This file contains hidden or 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 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