Last active
February 1, 2018 20:22
-
-
Save lubien/93279c4c6bb97d4e2789838b3e320ca8 to your computer and use it in GitHub Desktop.
FreeCodeCamp count. Count how many stuff you'd have to do on FreeCodeCamp (wrote on devtools, inb4: clean code)
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
JSON.stringify(Array.from(document.querySelectorAll('#accordion > *')).map((node, i, items) => { | |
if (node.nodeName !== 'H2') return false | |
const next = items[i + 1] | |
return { | |
title: node.querySelector('a').innerText.trim(), | |
items: Array.from(next.querySelectorAll('#nested > *')).map((node, i, items) => { | |
if (node.nodeName !== 'H3') return false | |
const next = items[i + 1] | |
return { | |
title: node.querySelector('a').innerText.trim(), | |
time: node.querySelector('.challengeBlockTime').innerText.trim().slice(1, -1), | |
items: next.querySelectorAll('p').length | |
} | |
}).filter(x => x) | |
} | |
}).filter(x => x) | |
, null, ' ') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment