Last active
April 23, 2017 13:29
-
-
Save cauerego/60e96160ce94340b040f6e2234ef2711 to your computer and use it in GitHub Desktop.
made for https://plus.google.com/+CaueRego/posts/939QeuTZd8a to find out what is the month with most posts in this ryan reynolds "funny dad" tweet collection: http://www.huffingtonpost.com/entry/ryan-reynolds-twitter-dad_us_589a4854e4b04061313a25e0
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
Number.prototype.pad = function(size) { | |
var s = String(this); | |
while (s.length < (size || 2)) {s = "0" + s;} | |
return s; | |
} | |
var times = []; | |
document.querySelectorAll('twitterwidget').forEach( elem => { | |
let e = elem.shadowRoot.querySelector('time').textContent | |
let m = e.match(/-.*?([^\d\s]+)/)[1] | |
let d = Number(e.match(/-.*?([\d]+)/)[1]).pad(2) | |
let y = e.match(/-.*?[^\d\s]+\s(\d*)/)[1] | |
let tt = elem.shadowRoot.querySelector('.Tweet-text').textContent | |
let tb = Array.from(elem.shadowRoot.querySelectorAll('.TweetAction.web-intent')).reduce( (a,b) => a.textContent +' '+ b.textContent ) | |
times.push([m, m + y + d, tt, [e, tb, elem]]) | |
}) | |
times.sort( (a,b) => a[1].localeCompare(b[1]) ) | |
times.forEach( item => console.log(item[0]) ) // try removing [0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment