Last active
July 26, 2018 09:27
-
-
Save leggsimon/cc9fe96391a6b951e88d41045e93a001 to your computer and use it in GitHub Desktop.
This file contains 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 toBool = str => { | |
if (!str) { | |
return false | |
} | |
return str === 'true' | |
? true | |
: str === 'false' | |
? false | |
: true | |
} | |
let tweets = [...document.querySelectorAll('.tweet')].map(tweet => { | |
const { attributes } = tweet | |
return { | |
screenName: attributes['data-screen-name'] && attributes['data-screen-name'].value, | |
retweet: Boolean(attributes['data-retweeter'] && attributes['data-retweeter'].value), | |
retweeter: attributes['data-retweeter'] && attributes['data-retweeter'].value, | |
youFollow: toBool(attributes['data-you-follow'] && attributes['data-you-follow'].value), | |
followsYou: toBool(attributes['data-follows-you'] && attributes['data-follows-you'].value), | |
href: `https://twitter.com${attributes['data-permalink-path'] && attributes['data-permalink-path'].value}`, | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment