Skip to content

Instantly share code, notes, and snippets.

@Jonasdero
Last active June 11, 2019 06:21
Show Gist options
  • Save Jonasdero/47ee2998a50775f333f8f88381750c8b to your computer and use it in GitHub Desktop.
Save Jonasdero/47ee2998a50775f333f8f88381750c8b to your computer and use it in GitHub Desktop.
function Sleep(milliseconds) {
return new Promise(resolve => setTimeout(resolve, milliseconds));
}
stories = [];
async function getStories() {
for (let i = 0; i < 50; i++) {
window.scrollTo(0, document.body.scrollHeight);
await Sleep(250);
}
for (let h of document.getElementsByTagName("h3")) {
var length = h.childNodes[0].href.split('?')[0].split('/').length
stories.push({
url: h.childNodes[0].href.split('?')[0],
title: h.childNodes[0].href.split('?')[0].split('/')[length - 1]
});
}
console.log(JSON.stringify(stories));
}
getStories();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment